How to fix Python Numpy/Pandas installation?

前端 未结 9 497
说谎
说谎 2020-12-24 06:13

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6.

I tried this

$ sudo easy_install pandas
Sear         


        
相关标签:
9条回答
  • 2020-12-24 06:34

    I work with the guys that created Anaconda Python. You can install multiple versions of python and numpy without corrupting your system python. It's free and open source (OSX, linux, Windows). The paid packages are enhancements on top of the free version. Pandas is included.

    conda create --name np17py27 anaconda=1.4 numpy=1.7 python=2.7
    export PATH=~/anaconda/envs/np17py27/bin:$PATH
    

    If you want numpy 1.6:

    conda create --name np16py27 anaconda=1.4 numpy=1.6 python=2.7
    

    Setting your PATH sets up where to find python and ipython. The environments (np17py27) can be named whatever you would like.

    0 讨论(0)
  • 2020-12-24 06:35

    Don't know if you solved the problem but if anyone has this problem in future.

    $python
    >>import numpy
    >>print(numpy)
    

    Go to the location printed and delete the numpy installation found there. You can then use pip or easy_install

    0 讨论(0)
  • 2020-12-24 06:42

    This worked for me under 10.7.5 with EPD_free-7.3-2 from Enthought:

    Install EPD free, then follow the step in the following link to create .bash_profile file.

    http://redfinsolutions.com/blog/creating-bashprofile-your-mac

    And add the following to the file.

    PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$(PATH)}"
    export PATH
    

    Execute the following command in Terminal

    $ sudo easy_install pandas
    

    When finished, launch PyLab and type:

    In [1]: import pandas
    
    In [2]: plot(arange(10))
    

    This should open a plot with a diagonal straight line.

    0 讨论(0)
  • 2020-12-24 06:42

    If you are using a version of enthought python (EPD) you might want to go directly to your site-packages and reinstall numpy. Then try to install pandas with pip. You will have to modify your installation prefix for that.

    If the problem persists (as it did with me) try downloading pandas tar ball, unpack it in your site packages and run setup.py install from your pandas directory.

    If you got your dependencies right you can import pandas and check it imports smoothly.

    0 讨论(0)
  • 2020-12-24 06:44

    I had this exact problem.

    The issue is that there is an old version of numpy in the default mac install, and that pip install pandas sees that one first and fails -- not going on to see that there is a newer version that pip herself has installed.

    If you're on a default mac install, and you've done pip install numpy --upgrade to be sure you're up to date, but pip install pandas still fails due to an old numpy, try the following:

    $ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
    $ sudo rm -r numpy
    $ pip install pandas
    

    This should now install / build pandas.

    To check it out what we've done, do the following: start python, and import numpy and import pandas. With any luck, numpy.__version__ will be 1.6.2 (or greater), and pandas.__version__ will be 0.9.1 (or greater).

    If you'd like to see where pip has put (found!) them, just print(numpy) and print(pandas).

    0 讨论(0)
  • 2020-12-24 06:48

    I had the same problem and, in my case, the problem was that python was looking for packages in some ordered locations, first of all the default computer one where default old packages are.

    To check what your python is looking for you can do:

    >>> import sys
    >>> print '\n'.join(sys.path)
    

    This was outputting the directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' before pip or brew or port folders.

    The simple solution is:

    export PYTHONPATH="/Library/Python/2.7/site-packages:$PYTHONPATH"
    

    This worked well for me, I advise you to add this line to your home bash_profile file for the next time. Remember that sys.path is built using the current working directory, followed by the directories in the PYTHONPATH environment variable. Then there are the installation-dependent default dirs.

    0 讨论(0)
提交回复
热议问题