gpt4 book ai didi

在虚拟环境中用pip安装的Python包在eclipse中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 18:42:14 26 4
gpt4 key购买 nike

我是 pyDev 和 Eclipse 的新手。我正在疯狂地尝试弄清楚如何从 Eclipse 中运行新安装的软件包(这样我就可以在控制台中看到结果)。我确实使用此处找到的指令在 Eclipse 中设置了解释器以指向虚拟环境:http://www.caktusgroup.com/blog/2011/08/31/getting-started-using-python-eclipse/

这就是我所做的。创建虚拟环境并使用 pip 安装新包(pandas)。然后我测试一些代码

from pandas.io.data import DataReader

如果我通过在虚拟环境中调用 python 解释器来测试这一行,则一切正常。但是,如果我在 Eclipse 中运行该行,则会出现错误。

一切都无济于事。以下是我收到的错误:

'module' object has no attribute 'tslib'
Traceback (most recent call last):
File "/Users/tomasisakowitz/Dropbox/workspace/Portfolio/Portfolio/transactions.py", line 474, in <module>
from pandas.io.data import DataReader
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "tslib.pyx", line 31, in init pandas.tslib (pandas/tslib.c:48782)
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/dateutil/parser.py", line 22, in <module>
from io import StringIO
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/io/__init__.py", line 1, in <module>
import sql
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/io/sql.py", line 10, in <module>
from pandas.core.datetools import format as date_format
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/core/datetools.py", line 3, in <module>
from pandas.tseries.tools import *
File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/tseries/tools.py", line 8, in <module>
import pandas.tslib as tslib
AttributeError: 'module' object has no attribute 'tslib'

最佳答案

要将 virtualenv 添加到 Eclipse PyDev 工作区,请转至 Window 菜单条目并选择首选项,在打开的对话框中转至 PyDev->Iterpreter-Python。

在“库”选项卡中单击“新建文件夹”按钮并添加您的虚拟环境。目录。

我的看起来像

/home/guy/.virtualenvs/my-env/lib/python2.7/site-packages/

关于在虚拟环境中用pip安装的Python包在eclipse中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20278393/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com