pandas Python3 和熊猫
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18926696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python3 and pandas
提问by dwanderson
I have checked some other SO answers and googled somewhat extensively and cannot seem to find someone who has asked/answered this:
我检查了其他一些 SO 答案,并在 google 上进行了广泛的搜索,但似乎找不到提出/回答这个问题的人:
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.2 I then modified my $PYTHONPATH to have the directory where pandas was installed, full aware that this might create an issue:
我正在运行 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 以拥有安装熊猫的目录,完全意识到这可能会产生问题:
/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
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?
所以我显然在这里错过了一些东西。请注意,由于我自己刚刚完成了所有这些 python 安装,并且仍在学习,我的 $PYTHONPATH 可能需要更新;现在里面唯一的东西就是上面提到的目录。我应该在那里有其他目录吗?
(If you need any more information about my system, etc., please just comment.)
(如果您需要有关我的系统等的更多信息,请发表评论。)
回答by zero323
Update
更新
As mentioned below, pandas is now available for python 3.3, 3.4 and 3.5 source
如下所述,pandas 现在可用于 python 3.3、3.4 和 3.5 源
For system wide install use:
对于系统范围的安装使用:
sudo apt-get install python3-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:
如果此信息http://packages.ubuntu.com/precise/python/是正确的,则没有适用于 Python 3 的 Pandas 包。您可以使用 virtualenv 安装当前的 Pandas:
apt-get install python-virtualenv virtualenvwrapper
mkvirtualenv -p python3 pandas_env
pip install pandas
Generally it is a good idea to create separate virtual environments when working with Python and to avoid manual messing with system wide packages.
通常,在使用 Python 时创建单独的虚拟环境并避免手动弄乱系统范围的包是一个好主意。
回答by timeislove
there is a python3-pip which will install pip-3.3 instead of pip. the pip-3.3 will install the pandas package into python3.3
有一个 python3-pip 将安装 pip-3.3 而不是 pip。pip-3.3 会将 pandas 包安装到 python3.3 中
回答by dmeu
You may just install it by sudo apt-get install python3-pandas
if you'd prefer a system-wide installation
sudo apt-get install python3-pandas
如果您更喜欢系统范围的安装,则可以直接安装它
回答by Rahul Singhai
I use MacOSx and I manage to install it using:
我使用 MacOSx 并设法使用以下方法安装它:
brew install python3
sudo pip3 install --upgrade pip
pip3 install pandas
Check the installation using:
使用以下命令检查安装:
$python3
>>>import pandas as pd
>>>exit()
回答by Makara Set
sudo apt update
sudo apt install python3-pip
sudo pip3 install pandas
回答by Dan Quinn
I would highly recommend that you install, and learn how to use, Anaconda to manage your python environments.It is superior to using pip, or virtualenv, pyenv or any of the wrappers for that stuff. Check it out:
我强烈建议您安装并学习如何使用 Anaconda 来管理您的 Python 环境。它优于使用 pip、virtualenv、pyenv 或任何包装器。一探究竟: