Windows部署pyspider指南
Posted 天生神经
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows部署pyspider指南相关的知识,希望对你有一定的参考价值。
1.安装python 2.7
下载地址:https://www.python.org/downloads/,记得要勾选最后的添加环境变量。
2.安装pyspider
打开命令提示符=》输入pip install pyspider
3.新建文件夹(个人需求)
在C:\Python27\Lib\site-packages下新建文件夹pyspider_helper用于存放辅助py文件
4.安装Microsoft Visual C++ Compiler for Pyhon 2.7
下载地址:http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
5.安装第三方库出现 Python version 2.7 required, which was not found in the registry解决办法
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()
运行此段代码。
6.安装mysql驱动
下载驱动:
64位:MySQL-python-1.2.3.win-amd64-py2.7.exe
32位: MySQL-python-1.2.5.win32-py2.7.exe
我的服务器上装的上方32位的,装64会报版本错误,很奇怪。
7.安装MySQLdb
命令提示符下输入:pip install mysql
8.安装mysql-connector
下载地址 https://dev.mysql.com/downloads/file/?id=472568
9.安装阿里云对象存储
文档地址:https://help.aliyun.com/document_detail/32026.html?spm=a2c4g.11174283.6.690.fJtbIT
命令提示符输入:pip install oss2
10.其他依赖的库
PIL:pip install Pillow
以上是关于Windows部署pyspider指南的主要内容,如果未能解决你的问题,请参考以下文章
windows环境安装phantomjs和pyspider遇到的问题