问题描述
我已经检查了其他一些答案,并在Google上进行了广泛的搜索,似乎找不到有人问过/回答过这个问题:
I have checked some other SO answers and googled somewhat extensively and cannot seem to find someone who has asked/answered this:
我正在运行Ubuntu 12.04.我安装了python2.7和python3.2.(我运行了sudo apt-get install python-numpy,python3-numpy以及与scipy类似的文件).我跑了sudo apt-get install python-pandas.它与python2.7完美配合.它不会在python3.2中导入然后,我修改了$ PYTHONPATH,使其具有安装熊猫的目录,完全意识到这可能会引起问题:
I am running Ubuntu 12.04.I have python2.7 and python3.2 installed.(I ran sudo apt-get install python-numpy, python3-numpy, and similar with scipy).I ran sudo apt-get install python-pandas.It works perfectly fine with python2.7.It does not import in python3.2I then modified my $PYTHONPATH to have the directory where pandas was installed, full aware that this might create an issue:
/usr/lib/pymodules/python2.7
现在,当我尝试导入时,我得到了
Now when I try to import, I get
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/pandas/__init__.py", line 10, in <module>
import pandas.lib as lib
ImportError: /usr/lib/pymodules/python2.7/pandas/lib.so: undefined symbol: _Py_ZeroStruct
所以我显然在这里错过了一些东西.需要说明的是,由于我自己亲自进行了所有这些python安装,并且仍在学习中,因此我的$ PYTHONPATH可能需要更新.现在,其中唯一的东西就是上面提到的目录.我应该在那里有其他目录吗?
So I've obviously missed something here. As a note, since I've just been doing all these python installations myself, and am still learning, my $PYTHONPATH may need updating; right now the only thing in it is the directory mentioned above. Are there other directories I should have in there, standardly?
(如果您需要有关我的系统等的更多信息,请发表评论.)
(If you need any more information about my system, etc., please just comment.)
推荐答案
更新
如下所述,pandas现在可用于python 3.3、3.4和3.5源代码
Update
As mentioned below, pandas is now available for python 3.3, 3.4 and 3.5source
对于系统范围的安装,请使用:
For system wide install use:
sudo apt-get install python3-pandas
原文:
如果此信息 http://packages.ubuntu.com/precise/python/是正确的,则没有适用于Python 3的pandas软件包.您可以使用virtualenv安装当前的pandas:
Original:
If this information http://packages.ubuntu.com/precise/python/ is correct there is no pandas package for Python 3. You can install current pandas using virtualenv:
apt-get install python-virtualenv virtualenvwrapper
mkvirtualenv -p python3 pandas_env
pip install pandas
通常,在使用Python时创建单独的虚拟环境是一个好主意,并且避免手动混乱系统范围的软件包.
Generally it is a good idea to create separate virtual environments when working with Python and to avoid manual messing with system wide packages.
这篇关于Python3和 pandas 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!