winPython科学计算平台及NeuroLab库的安装与配置

来源:互联网 发布:计算机 数学 知乎 编辑:程序博客网 时间:2024/05/17 15:58

1、安装WinPython 集成计算包

    Python我是直接安装的WinPython集成计算包,WinPython 集成计算包集成了Numpy等第三方Python科学计算库,安装WinPython 后,Numpy等计算库和Python 2.7会一同被安装。

    WinPython并不会像Python官方的Windows平台安装程序一样在安装时往注册表中写入相关信息。同时,一些工具的安装或运行需要读取注册表中的Python信息,比如mlpy的安装程序。我安装适用于Python 2.7的mlpy-3.5.0.win32-py2.7.exe时就因为"Python version 2.7 required, which was not found in the registry."未读取到注册表中的Python信息而失败,所以需要先配置window注册信息,细节如下:

    将下面的代码复制并保存为一个Python文件(比如registerpython.py)

# -*- coding: utf-8 -*-"""Created on Tue Jun 02 16:26:52 2015@author: dapenghuang"""import sysfrom _winreg import *# tweak as necessary version = sys.version[:3] installpath = "E:\python\winpython_anzhuang\WinPython-32bit-2.7.10.1\python-2.7.10" #更换成python所在地址 regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)installkey = "InstallPath"pythonkey = "PythonPath"pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (installpath, installpath, installpath)def RegisterPy():    print "begin RegisterPy "    try:        print "open key : %s"%regpath        reg = OpenKey(HKEY_CURRENT_USER, regpath)    except EnvironmentError as e:            try:                       reg = CreateKey(HKEY_CURRENT_USER, regpath)             SetValue(reg, installkey, REG_SZ, installpath)             SetValue(reg, pythonkey, REG_SZ, pythonpath)            CloseKey(reg)         except:             print "*** EXCEPT: Unable to register!"             return                             print "--- Python", version, "is now registered!"         return       if (QueryValue(reg, installkey) == installpath and         QueryValue(reg, pythonkey) == pythonpath):             CloseKey(reg)             print "=== Python", version, "is already registered!"             return CloseKey(reg)     print "*** ERROR:Unable to register!"     print "*** REASON:You probably have another Python installation!"def UnRegisterPy():    #print "begin UnRegisterPy "    try:        print "open HKEY_CURRENT_USER key=%s"%(regpath)        reg = OpenKey(HKEY_CURRENT_USER, regpath)        #reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)    except EnvironmentError:          print "*** Python not registered?!"        return    try:       DeleteKey(reg, installkey)       DeleteKey(reg, pythonkey)       DeleteKey(HKEY_LOCAL_MACHINE, regpath)    except:       print "*** Unable to un-register!"    else:       print "--- Python", version, "is no longer registered!"            if __name__ == "__main__":      RegisterPy()

然后在在win7命令行中运行:
python 文件路径/registerpython.py #WinPython安装得到的python需要配置环境变量

 

    这样就成功向注册表中写入了相关Python安装信息。

2、安装 BeautifulSoup (解析和分类网页)

    首先下载 BeautifulSoup源码,其官网为:http://www.crummy.com/software/BeautifulSoup/。
    然后解压后运行以下命令:


出现下面即表示BeautifulSoup安装成功。

 

3、安装NeuroLab

NeuroLab是用Python编写的神经网络库。下面的页面下载Neurolab(http://code.google.com/p/neurolab/downloads/list地址因为谷歌被禁不能访问):

https://pypi.python.org/pypi/neurolab

解压后我用命令行运行如下命令一直未能成功:


改为使用WinPython自带的WinPython Control Panel进行安装,直接用WinPython Control Panel读取未解压前的NeuroLab文件,即可安装完毕,同时在python安装目录的Python27\Lib\site-packages下,就可以看到neurolab的文件夹。

0 0
原创粉丝点击