Python中的Numpy、SciPy、MatPlotLib安裝教程

之前採用python來進行數據分析,就把這些安裝了。
我的環境是python 2.7 pip window7 64位操作系統 pycharm編譯器。(環境不一樣也是基本可以參照這個教程安裝的)
但是對於一些小白來說,網上有很多第三方資源都是在官網下載好以後上傳的,下載的時候需要一定的積分,而對於有一部份人來說,積分不夠或者是其他什麼的。這個教程是基於Numpy、SciPy、MatPlotLib的官網來的直接按照操作步驟來就可以安裝了。
(1)安裝NumPy,點擊下列網址進去,找到自己的版本,例如我的python是2.7。再下載相應的exe文件。
NumPy: http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/

頁面截圖
這裏寫圖片描述
(2)安裝MatPlotLib。安裝方法參考自網址:http://matplotlib.org/users/installing.html
如果不想看網址的話,直接採用下面的這個方法(網址方法翻譯過來的):

  1. window下打開命令行:win+R ,之後 輸入cmd打開命令行
  2. 執行python -m pip install -U pip setuptools
  3. 執行完上述命名行之後再執行python -m pip install matplotlib

運行截圖
這裏寫圖片描述


安裝完成
這裏寫圖片描述


這樣就可以了,它會自己幫你安裝所需要的環境配置的東西(前提是你已經安裝好pip和python運行環境,這個網上的教程還是很多的)


測試MatPlotLib和Numpy是否安裝成功:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : SundayCoder-俊勇
# @File    : teset.py
import numpy as np
import matplotlib.pyplot as plt

N = 5
menMeans = (20, 35, 30, 35, 27)
menStd =   (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)

womenMeans = (25, 32, 34, 20, 25)
womenStd =   (3, 5, 2, 3, 3)
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)

# add some
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind+width)
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )

ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )

def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
                ha='center', va='bottom')

autolabel(rects1)
autolabel(rects2)

plt.show()

運行截圖:
這裏寫圖片描述
到這一步就安裝好了Numpy、MatPlotLib。

對於測試是否安裝的程序是網上隨便找的,若是造成了侵權請聯繫我刪除


(3)SciPy的安裝打開網址可以看到目前是python3.4的exe,如果你的python是3.4版本的你就直接下載。
SciPy:https://sourceforge.net/projects/scipy/files/
運行截圖
這裏寫圖片描述


如果你的是2.7版本的話呢?
打開:https://sourceforge.net/projects/scipy/files/scipy/0.16.0/
找到你的版本,和Numpy的安裝一樣的一樣的。
運行截圖:
這裏寫圖片描述

Ok 安裝完畢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章