Python3 and pandas

I checked a few other SO answers and searched several times and could not find someone who 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 etc. with scipy). I ran sudo apt-get install python-pandas. It works great with python2.7. It is not imported in python3.2. Then I changed my $ PYTHONPATH to the directory in which pandas was installed, fully aware that this could create a problem:

/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 obviously missed something. As a side note, since I just did all these python installations myself and am still involved, my PYTHONPATH may need to be updated; now the only thing in it is the directory mentioned above. Are there other directories that I should have there as standard?

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

+10
pandas ubuntu
source share
6 answers

Update

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

For a system installation, use:

 sudo apt-get install python3-pandas 

Original:

If this information http://packages.ubuntu.com/precise/python/ is correct, the pandas package is for Python 3. You can install the current pandas using virtualenv:

 apt-get install python-virtualenv virtualenvwrapper mkvirtualenv -p python3 pandas_env pip install pandas 

As a rule, it is recommended that you create separate virtual environments when working with Python and avoid manually messing with system packages.

+16
source share

there is python3-pip which will install pip-3.3 instead of pip. pip-3.3 will install pandas package in python3.3

+3
source share

You can simply install it on sudo apt-get install python3-pandas if you prefer a system-wide installation

+2
source share

I am using MacOSx and I am able to install it using:

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

Verify the installation using:

 $python3 >>>import pandas as pd >>>exit() 
0
source share
 sudo apt update sudo apt install python3-pip sudo pip3 install pandas 
0
source share

I highly recommend you install and learn how to use Anaconda to manage your python environments. This is better than using pip or virtualenv, pyenv, or any shell for this stuff. Check this:

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

-one
source share

All Articles