Python安装及Scrapy配置中遇到的BUG及解决方案

来源:互联网 发布:java.util.arrays 编辑:程序博客网 时间:2024/06/05 09:00

win7下同时安装python2 和 python3:

将两个版本的python安装目录中的如下文件分别重命名:

python.exe和pythonw.exe分别重命名为python2(或3).exe和pythonw2(或3).exe


将两个版本的的安装路径分别加入环境变量中的path:

【D:\python2713\py2\Scripts】和【D:\python2713\py2】


之后在cmd运行:

python2 --version  显示Python 2.7.13

python3 --version  显示Python 3.5.2


表明配置成功



http://scrapy-chs.readthedocs.io/zh_CN/latest/intro/install.html#scrapy

跟着上面的链接走

直到安装完pip都是没问题的

接下来参考:

http://cuiqingcai.com/912.html

要先安装pyopenssl

D:\>pip install pyopenssl
Collecting pyopenssl
  Could not fetch URL https://pypi.python.org/simple/pyopenssl/: There was a problem confirming the
L: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement pyopenssl (from versions: )
No matching distribution found for pyopenssl


应该使用如下命令:

pip install --trusted-host pypi.python.org pyopenssl

姿势来自:

https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi


接下来的pipinstalllxml &&pipinstallScrapy 都要在install后面加上

 --trusted-host pypi.python.org 


显示安装成功了,不过按照他给的验证方式,在cmd中输入Scrapy是会报错的:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)


解决方案:

在 python 的 Lib\site-packages 文件夹下新建一个 sitecustomize.py:

import sys    sys.setdefaultencoding('gb2312')  

参:

http://wiki.jikexueyuan.com/project/python-crawler/scrapy-example.html


mdzz....至此终于告一段落,环境配置成功




原创粉丝点击