Python2.7的环境搭建 py2.7 beautifulSoup 、Scrapy 、selenium 、phantomis

py2.7 beautifulSoup 、Scrapy 、selenium 、phantomjs

           文章参考:[[Installing easy_install and pip for Python](http://blog.troygrosfield.com/2010/12/18/installing-easy_install-and-pip-for-python/)](http://blog.troygrosfield.com/2010/12/18/installing-easy_install-and-pip-for-python/)

1.[下载python2.7]
(http://www.pc6.com/softview/SoftView_67665.html)
安装完之后,设置环境变量
2.setuptool(easy_install)的安装的官方文档
https://pypi.python.org/pypi/setuptools#windows-simplified
setuptool的下载地址
ez_setup.py
安装完之后,设置环境变量
保存文件为ez_setup.py,并用 python运行。

文件在python的Script目录。

(3)安装pip
进入命令行,然后把目录切换到python的安装目录下的Script文件夹下,运行 easy_inatall pip。

(4)安装 beautifulSoup
easy_install beautifulsoup4
或者
pip install beautifulsoup4
(5)安装 scrapy
pip install scrapy

错误:error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpyt
解决办法:http://aka.ms/vcpython27 改网址。下载安装vc++ ,重新安装scrapy即可

错误:error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it …
打开注册表:桌面-》运行-》regedit
查看注册表,在HKLM\Software\Wow6432Node\Microsoft\VisualStudio\下

错误:
安装 :pip install lxml==3.4.2
cmd输入easy_install --allow-hosts=lxml.de,*.python.org lxml==3.4.2,然后回车,注意这里的3.4.2是版本号会更新,要依据官网的版本号。
最后重新安装 scrapy
‘ok’

(6)安装 selenium
pip install selenium

(7)安装phantomis
pip install phantomis
安装方法
http://www.waitalone.cn/selenium-phantomjs.html
或者:
http://vdisk.weibo.com/s/yYW13wR2C9Dcz
放在python的目录下,并添加到 环境变量
出现错误:
[python:UnicodeEncodeError]
错误原因:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u8888' in position 0: ordinal not in range(168),即ascii码无法被转换成unicode码。在仔细推敲后发现,我所使用的python2.7,默认编码是ascii格式。可以使用如下语句查看python默认编码格式:

解决办法:
方法1:
http://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20(http://www.cnblogs.com/DjangoBlog/p/3531092.html)
方法2:

http://www.cnblogs.com/DjangoBlog/p/3531092.html
(我使用的方法)
python安装目录下的lib\site-packages文件夹下新建一个sitecustomize.py,文件中的代码为:

import sys
sys.setdefaultencoding('utf-8')

在python3 之后,默认编码格式是unicode格式,就无需如此麻烦了。

错误: Could not find a version that satisfies the requirement phantomjs (from versios: )

pip install phantomjs==2.0.0.0

你可能感兴趣的:(Python2.7的环境搭建 py2.7 beautifulSoup 、Scrapy 、selenium 、phantomis)