1. 程式人生 > >【Python系列】之python2.7.6離線安裝Matplotlib

【Python系列】之python2.7.6離線安裝Matplotlib

1、離線安裝pip

(1)在python的安裝目錄下,新建packages資料夾,例:C:\Python27\packages

(2)https://pip.pypa.io/en/stable/installing/ 下載get-pip.py

(3)Unofficial Windows Binaries for Python Extension Packages 下載pip-8.1.2-py2.py3-none-any.whl和wheel-0.29.0-py2.py3-none-any.whl

python get-pip.py --no-setuptools --find-links=.\packages

get-pip.py options
–no-setuptools
If set, don’t attempt to install setuptools
–no-wheel
If set, don’t attempt to install wheel

2、檢視pip 支援的whl型別

AMD64

import pip._internal
print(pip._internal.pep425tags.get_supported())

WIN32

import pip
print(pip.pep425tags.get_supported())

在這裡插入圖片描述
在這裡插入圖片描述

3、安裝Matplotlib

(1)需要提前安裝:https://pypi.python.org/pypi/six

(2)需要提前安裝:https://pypi.python.org/pypi/numpy

特別說明:matplotlib的各種依賴包可參考:https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib

matplotlib的各種依賴庫在:https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下載,注意:下載的whl型別要和【2、檢視Pip支援的whl型別】一致,否則會出現:
Installing numpy from wheel format: “…is not a supported wheel on this platform”

安裝的時候出現的警告

Could not fetch URL https://pypi.python.org/simple/fastnumbers/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.python.org’, port=443): Max retries exceeded with url: /simple/fastnumbers/ (C
aused by SSLError(SSLError(1, ‘_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version’),)) - skipping
Could not find a version that satisfies the requirement fastnumbers (from versions: )
No matching distribution found for fastnumbers

https://superuser.com/questions/1336153/pip-cannot-fetch-url-because-of-an-error-with-the-ssl-certificate 介紹是由於python 2.7.6 SSL協議比較老導致的,python 2.7.15就沒這問題。不過如果是whl包的形式,目測對安裝過程無影響。

4、驗證是否安裝成功

# plot a sine wave from 0 to 4pi
from pylab import *
x_values = arange(0.0, math.pi * 4, 0.01)
y_values = sin(x_values)
plot(x_values, y_values, linewidth=1.0)
xlabel('x')
ylabel('sin(x)')
title('Simple plot')
grid(True)
savefig("sin.png")
show()

參考網址:http://www.voidcn.com/article/p-djcdtooa-rd.html

參考網址:https://www.lfd.uci.edu/~gohlke/pythonlibs/

參考網址:https://segmentfault.com/a/1190000006027207

參考網址:http://blog.csdn.net/sinat_26933727/article/details/68953193