python安装numpy科学计算模块

解决两个问题:

(1)Import Error: No module named numpy

(2)Python version 2.7 required, which was not found in the registry

(1)这种错误是因为没有安装numpy科学计算库,因此需要安装此模块。

  1. 首先下载正确的exe安装文件:numpy-MKL-1.8.0.win-amd64-py2.7.exe。

  2. 接着我们双加打开安装文件,点击运行按钮

  3. 安装过程很简单,点击下一步

  4. 在第一步,如果你看到自己的python的版本号和安装路径,说明你的numpy下载的版本是正确的,点击下一步

  5. 一直点击下一步即可完成安装

  6. 打开python,我们输入import numpy,如果没有提示错误信息,就说明我们安装完成

注意:在安装的过程中,可能会出现:

Python version 2.7 required, which was not found in the registry

这是因为python安装时没有写入到注册表中:

解决方法为:

写一个如下脚本,可以命名为:PythonRegister.py:

 1 # script to register Python 2.0 or later for use with win32all  
 2 # and other extensions that require Python registry settings  
 3 #  
 4 # written by Joakim Loew for Secret Labs AB / PythonWare  
 5 #  
 6 # source:  
 7 # http://www.pythonware.com/products/works/articles/regpy20.htm  
 8 #  
 9 # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html  
10    
11 import sys  
12    
13 from _winreg import *  
14    
15 # tweak as necessary  
16 version = sys.version[:3]  
17 installpath = sys.prefix  
18    
19 regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)  
20 installkey = "InstallPath"  
21 pythonkey = "PythonPath"  
22 pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (  
23     installpath, installpath, installpath  
24 )  
25    
26 def RegisterPy():  
27     try:  
28         reg = OpenKey(HKEY_CURRENT_USER, regpath)  
29     except EnvironmentError as e:  
30         try:  
31             reg = CreateKey(HKEY_CURRENT_USER, regpath)  
32             SetValue(reg, installkey, REG_SZ, installpath)  
33             SetValue(reg, pythonkey, REG_SZ, pythonpath)  
34             CloseKey(reg)  
35         except:  
36             print "*** Unable to register!"  
37             return  
38         print "--- Python", version, "is now registered!"  
39         return  
40     if (QueryValue(reg, installkey) == installpath and  
41         QueryValue(reg, pythonkey) == pythonpath):  
42         CloseKey(reg)  
43         print "=== Python", version, "is already registered!"  
44         return  
45     CloseKey(reg)  
46     print "*** Unable to register!"  
47     print "*** You probably have another Python installation!"  
48    
49 if __name__ == "__main__":  
50     RegisterPy()  

然后在CMD中执行:

启动命令切换到PythonRegister.py文件目录下执行

重新安装PIL,错误解决,安装成功。

此时就可以重新安装numpy库。

转载于:https://www.cnblogs.com/wt869054461/p/5035995.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值