设为首页 收藏本站
查看: 880|回复: 0

[经验分享] 转 Install Python, NumPy, SciPy, and matplotlib on Mac OS X

[复制链接]

尚未签到

发表于 2015-12-29 15:21:05 | 显示全部楼层 |阅读模式
Install Python, NumPy, SciPy, and matplotlib on Mac OS X




  A bit ago a friend and I both had fresh Mac OS X Lion installs so I helped him set up his computers with a scientific Python setup and did mine at the same time.
  These instructions are for Lion but should work on Snow Leopard or Mountain Lion without much trouble. On Snow Leopard you won’t install Xcode via the App Store, you’ll have to download it from Apple.
  After I’d helped my friend I found this blog post describing a procedure pretty much the same as below.
  Update: If doing all the stuff below doesn’t seem like your cup of tea, it’s also possible to install Python, NumPy, SciPy, and matplotlib using double-click binary installers (resulting in a much less flexible installation), see this post to learn how.
  

Xcode
  You will need Apple’s developer tools in order to compile Python and the other installs. On Lion you can install Xcode from the App Store, on Snow Leopard you’ll have to get an older Xcode from developer.apple.com.
  I use the Xcode editor because I like its syntax highlighting, code completion, and organizer. However, I use hardly any of its features and unless you’re an iOS or Mac developer you probably won’t either. If you prefer another editor it’s possible to get only the libraries and compilers that you need with the Command Line Tools for Xcode. (You’ll need a free Apple ID.) (See also http://www.kennethreitz.com/xcode-gcc-and-homebrew.html.)

Homebrew
  Homebrew is an excellent package manager for Mac OS X that can install a large number of packages. To install it simply launch a terminal and enter

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
  Homebrew installs things to /usr/local/ so you don’t need sudo permissions. To add Homebrew installed executables and Python scripts to your path you’ll want to add the following line to your .profile (or .bash_profile) file:

export PATH=/usr/local/bin:/usr/local/share/python:$PATH
  Normal executables go in /usr/local/bin/ and Python scripts installed by Homebrew go in/usr/local/share/python/.
  See https://github.com/mxcl/homebrew/wiki/The-brew-command or type brew help or man brewfor more info on Homebrew.

Install Python
  Now that you’ve got Homebrew installing Python is simple:

brew install python
  Homebrew will install a couple of packages required by Python and then Python itself. Don’t be surprised if this takes a couple minutes.
  Important: You should close your terminal and open a fresh one right now so that it has the updated PATH from the previous section. Otherwise you run the risk of executing the wrong scripts during the rest of these instructions.
  At this point you should be able to get a fresh terminal and type

which python
  and see

/usr/local/bin/python
  Homebrew is for installing system packages and tools; for managing Python add-ons we wantpip. Luckily easy_install, another Python package manager is installed by Homebrew and we can use it to install pip:

easy_install pip
Install NumPy
  Use pip to install NumPy:

pip install numpy
  This should install NumPy 1.6.1 (as of Feb. 2012).

Install SciPy
  We need gfortran to compile SciPy but it is not included with the other Xcode tools. Luckily, Homebrew can help us out again:

brew install gfortran
  When that’s done it’s a cinch to install SciPy:

pip install scipy
  This should install SciPy 0.10.

Install matplotlib
  To install matplotlib we need to revisit Homebrew one more time:

brew install pkg-config
  And the usual pip command:

pip install matplotlib
  This should install matplotlib 1.2.0. If it doesn’t you can try installing from the matplotlib development repo:

pip install git+git://github.com/matplotlib/matplotlib.git
  Congratulations! You should now have the basics of a scientific Python installation that’s easy to manage and upgrade using Homebrew and pip. Fire up Python and make sure things worked. The following should work in Python with no errors:

import numpy
import scipy
import matplotlib
  Enjoy!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-158077-1-1.html 上篇帖子: MAC OS 下 MYSQL 使用 UTF-8 的问题 下篇帖子: mac os x 10.5.8 ideneb 无法启动
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表