Python3 and pandas

我与影子孤独终老i 提交于 2019-12-18 13:13:28

问题


I have checked some other SO answers and googled somewhat extensively and cannot seem to find someone who has asked/answered this:

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:

/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?

(If you need any more information about my system, etc., please just comment.)


回答1:


Update

As mentioned below, pandas is now available for python 3.3, 3.4 and 3.5 source

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:

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.




回答2:


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




回答3:


You may just install it by sudo apt-get install python3-pandas if you'd prefer a system-wide installation




回答4:


I use MacOSx and I manage to install it using:

brew install python3
sudo pip3 install --upgrade pip
pip3 install pandas

Check the installation using:

$python3
>>>import pandas as pd
>>>exit()



回答5:


sudo apt update
sudo apt install python3-pip
sudo pip3 install pandas



回答6:


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:

https://store.continuum.io/cshop/anaconda/



来源:https://stackoverflow.com/questions/18926696/python3-and-pandas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!