在windows上安裝numpy

lt發表於2016-09-19

在https://bootstrap.pypa.io/get-pip.py下載get-pip.py.
在http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下載numpy-1.11.1+mkl-cp27-cp27m-win32.whl

D:\Python27>python \get-pip.py
Collecting pip
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 386kB/s
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 229kB/s
Installing collected packages: pip, wheel
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Successfully installed pip-8.1.2 wheel-0.29.0

這個操作會在D:\Python27\生成Scripts目錄,並安裝了以下檔案

 D:\Python27\Scripts 的目錄

[.]                                     [..]                                    
easy_install.exe                        f2py.py                                 f2py.pyc
easy_install-2.7.exe                    pip.exe                                 pip2.7.exe
pip2.exe                                wheel.exe

把第一步下載的whl檔案移動到D:\Python27\Scripts目錄,執行下面命令。

D:\Python27>cd scripts

D:\Python27\Scripts>pip install numpy-1.11.1+mkl-cp27-cp27m-win32.whl
Processing d:\python27\scripts\numpy-1.11.1+mkl-cp27-cp27m-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.1+mkl

D:\Python27\Scripts>cd ..

D:\Python27>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> m = np.matrix([[1,-2,3],[0,4,5],[7,8,-9]])
>>> m
matrix([[ 1, -2,  3],
        [ 0,  4,  5],
        [ 7,  8, -9]])
>>> m.T
matrix([[ 1,  0,  7],
        [-2,  4,  8],
        [ 3,  5, -9]])
>>> m.I
matrix([[ 0.33043478, -0.02608696,  0.09565217],
        [-0.15217391,  0.13043478,  0.02173913],
        [ 0.12173913,  0.09565217, -0.0173913 ]])
>>> m.I * m
matrix([[  1.00000000e+00,   1.11022302e-16,  -1.11022302e-16],
        [  0.00000000e+00,   1.00000000e+00,   0.00000000e+00],
        [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00]])
>>>

相關文章