【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-index --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())

【Python系列】之python2.7.6离线安装Matplotlib_第1张图片
【Python系列】之python2.7.6离线安装Matplotlib_第2张图片

3、安装Matplotlib

如果是whl包,安装方法如:

pip install wheel-0.29......whl

如果下载的不是whl包,在windows下解压的包里有setup.py,则安装方法为:
先到解压包的目录,如
【Python系列】之python2.7.6离线安装Matplotlib_第3张图片
然后使用命令:

python setup.py install

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

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

 依次用pip安装: pyparsing ; pytz; setuptools; six; cycler; pytz; python-deteutil; matplotlib;

特别说明: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

你可能感兴趣的:(【Python系列】之python2.7.6离线安装Matplotlib)