~~~~今天終於算是正式接觸scrapy了,測試的時候發現少裝了一個pywin32的模塊,然后安裝了好久,中間碰到好多坑,最后總算是裝好了。
首先我自己的py3.6是64位版本的,這是pywin32模塊的下載地址
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
里面有各種版本的,首先我先下了64位的3.6版本的,結果提示
當時也沒注意看,然后下載了個32位的試了試也不行,然后再看這個報的錯是因為注冊表問題,於是百度到下面一段代碼
import sys from winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version) installkey = "InstallPath" pythonkey = "PythonPath" pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( installpath, installpath, installpath ) def RegisterPy(): try: 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("*** 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("*** Unable to register!") print("*** You probably have another Python installation!") if __name__ == "__main__": RegisterPy()
這段代碼執行以后可以自動將py3.6安裝目錄直接添加進注冊表,檢查了下注冊表,的確出現了。
然后我在試了下64位的exe文件,還是提示找不到注冊表。
但是我又試了下32位的,卻可以安裝,然后調試了下,報錯 → ImportError: DLL load failed: %1 不是有效的 Win32 應用程序,模塊沒法用
后面我終於發現了問題所在,這個64位的exe默認找的是3.6-32,我就把注冊表里上面那張圖改成下面那張,問題解決了。
↓