机器学习Python环境安装

来源:互联网 发布:战争程序员白濑 动漫 编辑:程序博客网 时间:2024/06/05 09:40

刚开始接触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

点击“下一步”进行安装

当然如果下载的是.whl文件,需要编译一下:

首先:cmd 回车输入

python -m pip install -U pip
然后:在pyhton的script下拷入.whl;并切换对应目录:
运行pip install numpy-1.9.2+mkl-cp34-none-win_amd64.whl


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  

安装成功!




1 0
原创粉丝点击