Windows:
1.安裝python(版本為2.7或者3.5)
官網(wǎng):https://www.python.org/downloads
下載完后安裝怀泊,并在環(huán)境變量中配置
D:\Python27為python路徑
D:\Python27\Scripts\ 為pip路徑
2. 安裝virtualenv(python虛擬環(huán)境創(chuàng)建工具)
C:\Users\kernex>pip install virtualenv
安裝virtualenvwrapper (virtualenv管理工具 )
C:\Users\kernex>pip install virtualenvwrapper-win
3. 創(chuàng)建python虛擬環(huán)境
C:\Users\kernex>workon?(查看虛擬環(huán)境目錄)
C:\Users\kernex>mkvirtualenv --python=(*) py3scrapy?(使用指定python版本創(chuàng)建虛擬環(huán)境)
注:(*)=? C:\Users\kernex\AppData\Local\Programs\Python\Python35-32\python.exe?
4. 進(jìn)入和退出python虛擬環(huán)境
C:\Users\kernex>workon
C:\Users\kernex>workon py3scrapy
(py3scrapy) C:\Users\kernex>deactivate
5. 刪除python虛擬環(huán)境
C:\Users\kernex>rmvirtualenv py3scrapy
6. 在虛擬環(huán)境下安裝庫(kù)&框架
(py3scrapy) C:\Users\kernex>pip install requests
(py3scrapy) C:\Users\kernex>pip install -i https://pypi.douban.com/simple scrapy
(-i https://pypi.douban.com/simple 使用國(guó)內(nèi)豆瓣源加速安裝進(jìn)程)
Ps:安裝時(shí)可能會(huì)報(bào)錯(cuò):
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: http://landinghub.visualstudio.com/visual-cpp-build-tools
需要安裝twistedhttp://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted?下載twisted對(duì)應(yīng)版本的whl文件(如我的Twisted-17.9.0-cp35-cp35m-win32.whl)初嘹,cp后面是python版本鸟款,win32代表32位,運(yùn)行命令:
(py3scrapy) C:\Users\kernex>pip install E:\DesktopTemp\Twisted-17.9.0-cp35-cp35m-win32.whl
重新安裝scrapy:
(py3scrapy) C:\Users\kernex>pip install -i https://pypi.douban.com/simple scrapy
安裝成功灌具!