简体   繁体   English

如何在 Mac Mountain Lion OS X v10.8 上使用 pip 安装 Scipy

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

I'm having serious difficulty installing Scipy with pip on Mountain Lion.我在 Mountain Lion 上使用 pip 安装 Scipy 时遇到严重困难。 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?有人有什么建议吗?

Scipy is also available now via a homebrew tap. Scipy 现在也可以通过自制水龙头获得。 If you have homebrew installed:如果您安装了自制软件

brew tap samueljohn/python
brew install scipy

See more info here: homebrew-python在此处查看更多信息: homebrew-python

Pip has difficulties with scipy on OS X in general. Pip 通常在 OS X 上使用 scipy 有困难。 It is not trivial to install from the sources, so I advise against it.从源代码安装并非易事,因此我建议不要这样做。 In OS X you have a few better options:在 OS X 中,您有一些更好的选择:

  • Scipy superpack , a bunch of precompiled binaries Scipy superpack ,一堆预编译的二进制文件
  • Enthought Canopy (free or another) has already everything you'll need (numpy, scipy, matplotlib, etc.) Enthought Canopy (免费或其他)已经拥有您需要的一切(numpy、scipy、matplotlib 等)
  • Anaconda , a free scientific python distribution with probably all the packages you'll ever need. Anaconda ,一个免费的科学 python 发行版,可能包含你需要的所有包。
  • MacPorts , a comprehensive and flexible package manager that allows you to install and maintain a python distribution MacPorts ,一个全面而灵活的包管理器,允许您安装和维护 python 发行版
  • Homebrew , another popular package manager for OS X Homebrew ,另一个流行的 OS X 包管理器

Here is what worked for me for pip installing matplotlib and scipy inside a virtual environment (Mac OS X 10.9.2 Mavericks):以下是在虚拟环境(Mac OS X 10.9.2 Mavericks)中安装 matplotlib 和 scipy 对我有用的方法:

# 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. matplot lib 安装很快,但是 scipy 花了很长时间。

Just to add to what @Anton I. Sipos said.只是为了补充@Anton I. Sipos 所说的话。 I had the Enthought package installed but had issues with upgrading it, so I decided to go with a clean install using Homebrew .我安装了 Enthought 包,但在升级它时遇到了问题,所以我决定使用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:因此,经过一番搜索,我在 GitHub 上发现了一个samualjohn解决并为我工作的问题

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.问题显然是 Enthought 卸载说明未涵盖的站点包中的冲突。

NOTE: I had to install matplotlib with pip .注意:我必须使用pip安装matplotlib

I had similar issues installing scipy on OSX 10.9 Mavericks as well.我在 OSX 10.9 Mavericks 上安装 scipy 时也遇到了类似的问题。 What solved it for me is the following:为我解决的问题如下:

sudo pip list

was showing numpy, thus I did:正在显示 numpy,因此我这样做了:

sudo pip install --upgrade numpy

Afterwards然后

brew list

was showing gfortran.正在显示 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.因奇怪的 fortran 错误而失败。 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.在那之后工作。

I recently also had trouble getting scipy to install on a virtualenv.我最近也很难在 virtualenv 上安装 scipy。 My problem was that gfortran was not seen properly.我的问题是没有正确看到 gfortran。 I used macports sudo port install gcc48 and created a symlink to just gfortran by:我使用了 macports sudo port install gcc48并通过以下方式创建了一个指向 gfortran 的符号链接:

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.之后, pip install scipy在我的 virtualenv 上运行没有任何错误。

Installing scipy on Mac OS X with pip is possible!使用 pip 在 Mac OS X 上安装 scipy 是可能的! You will need the right C and Fortran compilers on your system to set up scipy.您将需要系统上正确的 C 和 Fortran 编译器来设置 scipy。 This page should help you:此页面应该可以帮助您:

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

Once you have done that, you should be able to install with pip install scipy .完成此操作后,您应该可以使用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.以前的海报@biophetik 给出了一个如何做到这一点的例子。

Also, I already had numpy installed in my virtual environment when I installed scipy.另外,当我安装 scipy 时,我已经在我的虚拟环境中安装了 numpy。 I'm not positive whether/how one depends on the other.我不确定一个是否/如何依赖另一个。

On Mavericks the following works (might also work on other versions):在 Mavericks 上,以下作品(可能也适用于其他版本):

If you haven't already, install pip如果您还没有,请安装pip

sudo easy_install pip

Then install/update scipy然后安装/更新scipy

sudo pip install scipy -U

For some reason pip installs scipy to出于某种原因pipscipy安装到

/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__"

I tryed everything: pip, macports,easy_install,... with Mac OS El Captain.我用 Mac OS El Captain 尝试了一切:pip、ma​​cports、easy_install……。 The only thing that worked for me was brew:唯一对我有用的是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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xdebug安装(php.ini)OS X 10.8(Mountain Lion) - Xdebug install (php.ini) OS X 10.8 (Mountain Lion) Mac OS X 10.8 Mountain Lion的内核调试工具包 - Kernel Debug Kit for Mac OS X 10.8 Mountain Lion 在Mac OS X 10.8 Mountain Lion上未调用该方法 - Method does not invoked on Mac OS X 10.8 Mountain Lion 如何为Mac OS X 10.8 Mountain Lion设置Java JDK环境变量 - How to Set Java JDK Environment Variable for Mac OS X 10.8 Mountain Lion 如何在Mac OS X Mountain Lion上安装rmagick? - How to install rmagick on Mac OS X Mountain Lion? 如何在Mac OS X Mountain Lion上安装pybrain? - How can I install pybrain on Mac OS X Mountain Lion? 如何在Mac OS X 10.8(山狮)中更改Homebrew的git origin远程位置? - How do I change the git origin remote location of Homebrew in Mac OS X 10.8 (mountain lion)? 如何在Mac OS X 10.8上的野生动物园中启用32位Java [Mountain Lion] - How to enable 32 bit Java in safari on Mac OS X 10.8 [Mountain Lion] 如何卸载Xcode 4.4命令行工具(Mac OS X 10.8 Mountain Lion)? - How to uninstall Xcode 4.4 command line tools (Mac OS X 10.8 Mountain Lion)? 如何在Mac OS X 10.8 Mountain Lion的非视网膜显示器上模拟视网膜显示器(HiDPI模式)? - How to simulate a retina display (HiDPI mode) in Mac OS X 10.8 Mountain Lion on a non-retina display?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM