winPython科學計算平臺及NeuroLab庫的安裝與配置
阿新 • • 發佈:2019-02-02
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)
python 檔案路徑/registerpython.py #WinPython安裝得到的python需要配置環境變數
2、安裝 BeautifulSoup (解析和分類網頁)
首先下載 BeautifulSoup原始碼,其官網為:http://www.crummy.com/software/BeautifulSoup/。
然後解壓後執行以下命令:
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)
然後在在win7命令列中執行:# -*- coding: utf-8 -*- """ Created on Tue Jun 02 16:26:52 2015 @author: dapenghuang """ import sys from _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()
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地址因為谷歌被禁不能訪問 ):
解壓後我用命令列執行如下命令一直未能成功:
改為使用WinPython自帶的WinPython Control Panel進行安裝,直接用WinPython Control Panel讀取未解壓前的NeuroLab檔案,即可安裝完畢,同時在python安裝目錄的Python27\Lib\site-packages下,就可以看到neurolab的資料夾。