1. 程式人生 > >mac安裝numpy,scipy,matplotlib

mac安裝numpy,scipy,matplotlib

mos cannot isp () args -c cycle fin edits

技術分享
SaintKings-Mac-mini:~ saintking$ python
Python 2.7.10 (default, Jul 30 2016, 18:31
:42) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> help() Welcome to Python 2.7! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http:
//docs.python.org/2.7/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords
", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". help> numpy
View Code

>>> import numpy as np

>>> np.multiply(1,3)

3

>>>

numpy安裝是完成的.

1.安裝numpy

2.安裝scipy

3.安裝matplotlib

help> scipy

help> matplotlib

經檢查都已經安裝成功.

測試一下:

技術分享
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 29, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/figure.py", line 36, in <module>
    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 20, in <module>
    import matplotlib.dates as _  # <-registers a date unit converter
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/dates.py", line 119, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "/Users/saintking/Library/Python/2.7/lib/python/site-packages/dateutil/rrule.py", line 19, in <module>
    from six.moves import _thread, range
ImportError: cannot import name _thread
View Code

解決一下這個問題.

因為python的版本太低.現在采用3.6

SaintKings-Mac-mini:~ saintking$ which python

/usr/bin/python

mv /usr/bin/python /usr/bin/python_backup

mv /usr/local/bin/python /usr/local/bin/python_backup

>>> import matplotlib.pyplot as plt

在很多時候我們希望忽略過去下載的安裝包,直接下載安裝可以使用–ignore-installed這個參數,比如我發現的的matplotlib的mplot3d部分有點問題,我想再重新下載安裝一遍,可以這麽做

這會把相關的包(numpy, pytz, six, python-dateutil, cycler, pyparsing, matplotlib)都下載安裝一遍

SaintKings-Mac-mini:~ saintking$ sudo pip install --upgrade --ignore-installed matplotlib

Password:

The directory ‘/Users/saintking/Library/Caches/pip/http‘ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag.

The directory ‘/Users/saintking/Library/Caches/pip‘ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag.

Collecting matplotlib

Downloading matplotlib-2.1.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (13.2MB)

100% |████████████████████████████████| 13.2MB 77kB/s

Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)

Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)

100% |████████████████████████████████| 61kB 901kB/s

Collecting numpy>=1.7.1 (from matplotlib)

Downloading numpy-1.13.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.6MB)

100% |████████████████████████████████| 4.6MB 164kB/s

Collecting pytz (from matplotlib)

Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)

100% |████████████████████████████████| 491kB 442kB/s

Collecting backports.functools-lru-cache (from matplotlib)

Downloading backports.functools_lru_cache-1.4-py2.py3-none-any.whl

Collecting six>=1.10 (from matplotlib)

Downloading six-1.11.0-py2.py3-none-any.whl

Collecting cycler>=0.10 (from matplotlib)

Downloading cycler-0.10.0-py2.py3-none-any.whl

Collecting subprocess32 (from matplotlib)

Downloading subprocess32-3.2.7.tar.gz (54kB)

100% |████████████████████████████████| 61kB 599kB/s

Collecting python-dateutil>=2.0 (from matplotlib)

Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)

100% |████████████████████████████████| 194kB 522kB/s

Installing collected packages: pyparsing, numpy, pytz, backports.functools-lru-cache, six, cycler, subprocess32, python-dateutil, matplotlib

Running setup.py install for subprocess32 ... done

Successfully installed backports.functools-lru-cache-1.4 cycler-0.10.0 matplotlib-2.1.0 numpy-1.13.3 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.2 six-1.11.0 subprocess32-3.2.7

SaintKings-Mac-mini:~ saintking$ python

Python 2.7.10 (default, Jul 30 2016, 18:31:42)

[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import matplotlib.pyplot as plt

>>> plt.bar(left=(0,1),height=(1,0.5))

/Library/Python/2.7/site-packages/matplotlib/__init__.py:1710: MatplotlibDeprecationWarning: The *left* kwarg to `bar` is deprecated use *x* instead. Support for *left* will be removed in Matplotlib 3.0

return func(ax, *args, **kwargs)

<Container object of 2 artists>

>>> plt.show()

>>>

顯示出來:

技術分享

 

mac安裝numpy,scipy,matplotlib