How to install Scipy with pip on Mac Mountain Lion OS X v10.8

↘锁芯ラ 提交于 2019-11-26 16:50:04

问题


I'm having serious difficulty installing Scipy with pip on Mountain Lion. I've tried:

sudo pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev

As suggested in various places on the web.

This leads to errors like:

ld: library not found for -lgcc
lipo: can't figure out the architecture type of: /var/tmp//ccC2HLVs.out

and several warnings (I assume not serious) before the errors.

Does anybody have any suggestions?


回答1:


Pip has difficulties with scipy on OS X in general. It is not trivial to install from the sources, so I advise against it. In OS X you have a few better options:

  • Scipy superpack, a bunch of precompiled binaries
  • Enthought Canopy (free or another) has already everything you'll need (numpy, scipy, matplotlib, etc.)
  • Anaconda, a free scientific python distribution with probably all the packages you'll ever need.
  • MacPorts, a comprehensive and flexible package manager that allows you to install and maintain a python distribution
  • Homebrew, another popular package manager for OS X



回答2:


Scipy is also available now via a homebrew tap. If you have homebrew installed:

brew tap samueljohn/python
brew install scipy

See more info here: homebrew-python




回答3:


Here is what worked for me for pip installing matplotlib and scipy inside a virtual environment (Mac OS X 10.9.2 Mavericks):

# See George's answer above
brew update
brew upgrade
brew install gfortran 

# See http://www.scipy.org/scipylib/building/macosx.html (the link Nathan Gould posted above)
export CXX=g++-5.1
export CC=gcc-5.1
export FFLAGS=-ff2c
sudo ln -s /usr/bin/gcc /usr/bin/gcc-5.1
sudo ln -s /usr/bin/g++ /usr/bin/g++-5.1

pip install matplotlib
pip install scipy

matplot lib installed quickly, but scipy took a long time.




回答4:


Just to add to what @Anton I. Sipos said. I had the Enthought package installed but had issues with upgrading it, so I decided to go with a clean install using Homebrew. Unfortunately just performing the tap and install didn't work well for me. So on searching a bit I found an issue on GitHub that samualjohn addressed and worked for me:

brew remove python
rm -rf /Library/Python/2.7/site-packages # it's save to delete this!
brew install python
pip install nose
brew install numpy
brew install scipy

The problem was clearly conflicts in the site-packages that the Enthought uninstall instructions did not cover.

NOTE: I had to install matplotlib with pip.




回答5:


I had similar issues installing scipy on OSX 10.9 Mavericks as well. What solved it for me is the following:

sudo pip list

was showing numpy, thus I did:

sudo pip install --upgrade numpy

Afterwards

brew list

was showing gfortran. I made sure I had the latest version by

brew update
brew upgrade

but

sudo pip install scipy 

was failing with a weird fortran error. Thus I uninstalled it and reinstalled it

sudo brew install gfortran
sudo brew uninstall gfortran

and to my great surprise

sudo pip install scipy 

worked after that.




回答6:


I recently also had trouble getting scipy to install on a virtualenv. My problem was that gfortran was not seen properly. I used macports sudo port install gcc48 and created a symlink to just gfortran by:

sudo ln -s /opt/local/bin/gfortran-mp-4.8 /opt/local/bin/gfortran

After that, pip install scipy worked without any errors on my virtualenv.




回答7:


On Mavericks the following works (might also work on other versions):

If you haven't already, install pip

sudo easy_install pip

Then install/update scipy

sudo pip install scipy -U

For some reason pip installs scipy to

/Library/Python/2.7/site-packages/

and does not remove the older version in

/System/Library/Frameworks/Python.framework/Versions/2.7//Extras/lib/python/scipy/

So just remove the old version and it works. Print the version number:

python -c "import scipy; print scipy.__version__"



回答8:


I tryed everything: pip, macports,easy_install,... with Mac OS El Captain. The only thing that worked for me was brew:

$ brew install scipy

After that, it will ask you to follow the instructions bellow:

$ brew link --overwrite numpy
$ mkdir -p /Users/adrieljr/Library/Python/2.7/lib/python/site-packages
$ echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> /Users/adrieljr/Library/Python/2.7/lib/python/site-packages/homebrew.pth



回答9:


Installing scipy on Mac OS X with pip is possible! You will need the right C and Fortran compilers on your system to set up scipy. This page should help you:

http://www.scipy.org/scipylib/building/macosx.html

Once you have done that, you should be able to install with pip install scipy.

As an additional troubleshooting note, you might need to create a symlink to your compiler so that the setup process can find it. A previous poster @biophetik gave an example of how to do this.

Also, I already had numpy installed in my virtual environment when I installed scipy. I'm not positive whether/how one depends on the other.



来源:https://stackoverflow.com/questions/12092306/how-to-install-scipy-with-pip-on-mac-mountain-lion-os-x-v10-8

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