Search code examples
ubuntupandaspython-3.2

Python3 and pandas


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.)


Solution

  • 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.