一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Installing scientific Python on Mac OS X

 dzh1121 2015-03-27
 我這里用的都是pip3。 這樣會(huì)安裝最新的numpy 等包裹。以及python3
另外,pip3的時(shí)候,要加sudo

Getting scientific Python running on a Mac is one of the biggest hurdles for data scientists who are just getting started (and, trust us, professionals too!). We'd usually steer readers toward one of the more popular articles on the subject, but it's gotten a bit stale. Therefore, here are updated step-by-step instructions for getting a basic environment set up.

In this guide we'll install the following packages:

  1. Quickstart
  2. Homebrew
  3. Python
  4. virtualenv and virtualenvwrapper    https://www./watch?v=N5vscPTWKOk
  5. NumPy
  6. SciPy
  7. matplotlib
  8. IPython and the Qt console

 

Quickstart

For the impatient, the following code will get you up and running without delay. Otherwise, please continue reading the rest of this post for step-by-step instructions and explanations.

NB: This code assumes Homebrew is installed; if it isn't, follow the instructions below! Also, be sure to follow any instructions Homebrew gives after each installation, such as modifying your path variables.

 

Homebrew

Homebrew's homepage puts it well: "Homebrew installs the stuff you need that Apple didn’t." (It used to say, "Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn't include with OS X," which may not be as catchy as the new wording, but does a better job explaining.) You will need to have XCode and its Command Line Tools installed first (get them in the App Store). Then, install Homebrew on your machine by pasting this into Terminal:

That's it. Try running brew update and brew doctor at the command line to make sure it's working properly.

You'll need to add the Homebrew directory to the front of your system path, in order to ensure that Homebrew-installed software is given priority over any other versions. To do so, open the .bash_profile in your user directory (that's the ~ directory or, more verbosely, /Users/[your_user_name]) and add the following line (if you don't have a .bash_profile, just create one with any text editor):

Restart Terminal so it picks up the new path. Homebrew is generally very good about alerting you to any action you need to take after it runs, including path modifications. Make sure to pay attention to its output.

 

Python

Now to the main event: Python. These instructions are for version 2.7.3. If you want to install something else, like Python3, just adjust the commands as required. With Homebrew, getting Python is quite easy:

This will also install package management tools like pip, which we'll need later. To get them to work seamlessly, add this to your .bash_profile:

To verify the installation, type which python into Terminal. You should see /usr/local/bin/python in response.

 

virtualenv

virtualenv is a tool that allows you to create isolated Python environments, each with its own set of packages and dependencies. This is useful for testing or managing package requirements (for example, if you build an application that is dependent on a certain version of a third-party package but another application requires a more recent version, you might break the first application by upgrading). This is not required, and all the commands below should work whether or not you are using virtualenv, so consider this step for convenience only. The only difference will be that directories (such as that returned by which pip) will point to the virtualenv rather than /usr/local.

First, install virtualenv and virtualenvwrapper, a tool that makes working with virtualenv somewhat easier:

Next, source the virtualenvwrapper script:

This will create a (hidden) virtualenv directory at ~/.virtualenv. Now you can create your first virtual environment:

Your new virtualenv test1 comes with a complete install of Python 2.7.3 and its own version of pip. It is activated by default, so running any pip command will only impact this environment. Note that if you deactivate the virtualenv, you will lose access to any packages installed in it. You can switch between virtualenvs with the workon command. To delete your test virtualenv, run rmvirtualenv test1.

 

Numpy

NumPy, of course, forms the basis of most scientific work in Python. NumPy can be installed with pip, but that method failed on Macs until quite recently (see pip issue #707). If you'd like to try it, simply execute the following in Terminal:

 

SciPy

SciPy requires a Fortran compiler. To acquire one, use Homebrew:

Once that installs, you may choose to install SciPy with pip:

 

matplotlib

Installing matplotlib, a versatile plotting library, follows the same pattern. However, you may have to install freetype first:

Either use pip:

 

IPython

If you're not using IPython as your interactive console, you should be. It improves on the stock Python console in every way. Installing IPython itself is a fairly straightforward pip command:

Getting the Qt Console to run is more difficult, but well worth it. First, you'll need to download the Qt library from this site. Once you have that set up, begin installing the prerequisites:

After installing pyqt, Homebrew will prompt you to add the following to your .bash_profile:

Continue installing prerequisites:

And that's all -- you should be able to launch the Qt console by executing ipython qtconsole. If you want to see the matplotlib output inline (and why wouldn't you?), then execute:

Fin.

We hope these instructions remove a common stumbling block for any data scientists getting started with scientific Python... and also those professionals who need a checklist for setting up new environments! After all, at some point we all start from square one.

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    老司机精品视频在线免费看| 亚洲最大福利在线观看| 久久成人国产欧美精品一区二区| 丰满少妇高潮一区二区| 丁香六月啪啪激情综合区| 台湾综合熟女一区二区| 国产女性精品一区二区三区 | 日韩一级一片内射视频4k| 在线免费看国产精品黄片| 日韩一区二区三区嘿嘿| 日韩精品一区二区三区av在线| 日韩欧美91在线视频| 欧美精品在线播放一区二区| 精品一区二区三区中文字幕 | 亚洲中文在线观看小视频| 日本深夜福利在线播放| 91欧美亚洲精品在线观看| 国产一区欧美一区二区| 91超频在线视频中文字幕| 老鸭窝老鸭窝一区二区| 丰满人妻少妇精品一区二区三区| 日本欧美在线一区二区三区| 久热99中文字幕视频在线| 人体偷拍一区二区三区| 中日韩美一级特黄大片| 熟女免费视频一区二区| 最新午夜福利视频偷拍| 日本福利写真在线观看| 午夜福利激情性生活免费视频| 日韩一区二区三区18| 国产水滴盗摄一区二区| 精品偷拍一区二区三区| 亚洲高清中文字幕一区二区三区| 黄片美女在线免费观看| 国产麻豆成人精品区在线观看| 国产又色又爽又黄又大| 大伊香蕉一区二区三区| 国产成人一区二区三区久久| 成人精品视频一区二区在线观看 | 国产亚洲欧美自拍中文自拍| 五月天丁香婷婷狠狠爱|