安裝pywin32報錯:python version 3.6 required,which was not fount in the registry(python3.6安裝scrapy) ...
在安裝scrapy時遇到問題
環境:win10(64位), Python3.6(64位)
安裝scrapy:
1、安裝wheel(安裝後,便支持通過wheel文件安裝軟體)
pip3 install wheel
2、安裝lxml、pyopenssl
lxml:解析XML的庫,很強大,做爬蟲BS4,selenium,XPATH都會用到
pip3 install lxml
pip3 install pyopenssl
3、安裝pywin32
下載網址: https://sourceforge.net/projects/pywin32/files/pywin32/
根據自己python版本下載64位或32位((註意:pywin32版本跟隨Python版本,即如果win是64位,但python是32位,pywin32要裝32位的,與win無關))
雙擊安裝(可能會遇到下列錯誤是註冊表問題)
安裝第三方庫出現Python version 3.6 required, which was not found in the registry錯誤解決
建立一個文件 register.py 內容如下. 然後執行該腳本.
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()
4、下載twisted
下載twisted的wheel文件:http://www.lfd.uci.edu/~gohlke/pythonlibs/
pip3 install 下載目錄\Twisted-17.9.0-cp36-cp36m-win_amd64.whl
安裝可能會報錯
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
說明電腦需要安裝visual C++ Build Tools 2015
5、安裝scrapy
pip3 install scrapy
6、大功告成
這是今天安裝scrapy時遇到的問題 明天會發一篇關於scrapy的詳細隨筆有興趣的可以關註