刚开始接触Python,许多朋友肯定都会很纠结。
Python安装的问题主要是版本兼容的问题。下载时请务必注意!下面以python2.7.9为例,
(1)下载python2.7.9.msi ;这个网上很容易找到。
(2)matplotlib是基于numpy的,所以必须先安装numpy。
numpy下载地址:http://sourceforge.net/projects/numpy/files/NumPy/
numpy下载版本为1.9.2
及下载文件为:numpy-1.9.2-win32-superpack-python2.7.exe
点击“下一步”进行安装
1. 检测版本:(实例)
2. >>> import numpy
3. >>> numpy.__version__
4. '1.9.2'
注意:必须保证版本为1.9.2
(3)下载matplotlib
Matplotlib下载地址: http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.4.3/windows/
Matplotlib下载版本:1.4.3
matplotlib-1.4.3.win32-py2.7
1. import matplotlib
2.
3. Traceback (most recent call last):
4. File "<pyshell#27>", line 1, in <module>
5. import matplotlib
6. File "D:\program files\Python27\lib\site-packages\matplotlib\__init__.py", line 105, in <module>
7. import six
8. ImportError: No module named six
测试发生错误,解决方案为:cmd
输入命令: python -m pip install six
再进行测试,出现如下问题:
1. <span style="font-size:14px;">>>> import matplotlib
2.
3. Traceback (most recent call last):
4. File "<pyshell#29>", line 1, in <module>
5. import matplotlib
6. File "D:\program files\Python27\lib\site-packages\matplotlib\__init__.py", line 116, in <module>
7. raise ImportError("matplotlib requires dateutil")
8. ImportError: matplotlib requires dateutil</span>
解决方案:
python -m pip install python-dateutil
再检测:
1. >>> import matplotlib
2.
3. Traceback (most recent call last):
4. File "<pyshell#30>", line 1, in <module>
5. import matplotlib
6. File "D:\program files\Python27\lib\site-packages\matplotlib\__init__.py", line 140, in <module>
7. raise ImportError("matplotlib requires pyparsing")
8. ImportError: matplotlib requires pyparsing
解决方案:
python -m pip install pyparsing
安装成功!