1.下載Python程序
首先訪問http://www.python.org/download/去下載最新的python版本。
根據(jù)需要下載 python2 或者python3, 同時注意自己的操作系統(tǒng)版本是64位還是32位,選擇符合自己的
這里介紹python2 的安裝
2.安裝下載包,一路next。
3.配置環(huán)境變量
右鍵計算機-->屬性-->高級系統(tǒng)設(shè)置-->環(huán)境變量-->
在系統(tǒng)變量里面找到 Path, 然后將python 安裝路徑加入進去, 注意里面的分號是英文格式的 ‘;’

打開cmd 終端參照下面,如果能顯示python 版本, python 就可以工作了
C:/>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> a = 'hello world'>>> PRint ahello world>>>4. 其他配置雖然至此python 能夠工作了,但是還有一些其他的內(nèi)容需要配置
我們使用python 的時候,難免要使用到一些第三方庫,或者一些架構(gòu),因此需要先把工具準(zhǔn)備好
4.1 pip 工具
首先 同樣的配置環(huán)境變量
將python 目錄下的Script 也加到環(huán)境變量中去
C:/Python27/Scripts
然后在命令行下執(zhí)行pip
但是很遺憾, 系統(tǒng)提示如下:
C:/Python27>pip'pip' 不是內(nèi)部或外部命令,也不是可運行的程序或批處理文件。為什么呢, 因為剛才的終端沒有關(guān)閉, 需要我們重新打開一下, 然后我們嘗試安裝一下 bs4C:/Python27/Scripts>pip install bs4Collecting bs4 Using cached bs4-0.0.1.tar.gzCollecting beautifulsoup4 (from bs4) Using cached beautifulsoup4-4.5.3-py2-none-any.whlInstalling collected packages: beautifulsoup4, bs4 Running setup.py install for bs4Successfully installed beautifulsoup4-4.5.3 bs4-0.0.1You are using pip version 7.1.2, however version 9.0.1 is available.You should consider upgrading via the 'python -m pip install --upgrade pip' command.系統(tǒng)提示我們, pip 的版本太低了, 那我們升級一下pip 的版本python -m pip install --upgrade pip接著執(zhí)行pip install bs4實驗一下是否安裝成功C:/Python27/Scripts>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import bs4>>>沒有報錯, 那就OK了4.2 利用easy_install 安裝 lxml
C:/Python27/Scripts>easy_install-2.7.exe lxmlSearching for lxmlReading https://pypi.python.org/simple/lxml/Best match: lxml 3.7.2Downloading https://pypi.python.org/packages/66/45/f11fc376f784c6f2e77ffc7a9d02374ff3ceb07ede8c56f918939409577c/lxml-3.7.2.tar.gz#md5=8dcf8d6c692Processing lxml-3.7.2.tar.gzWriting c:/windows/temp/easy_install-iudefp/lxml-3.7.2/setup.cfgRunning lxml-3.7.2/setup.py -q bdist_egg --dist-dir c:/windows/temp/easy_install-iudefp/lxml-3.7.2/egg-dist-tmp-4pweyfBuilding lxml version 3.7.2.Building without Cython.ERROR: 'xslt-config' 不是內(nèi)部或外部命令,也不是可運行的程序或批處理文件。** make sure the development packages of libxml2 and libxslt are installed **Using build configuration of libxslterror: Setup script exited with error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27報錯提示我們需要安裝 Microsoft Visual C++ 9.0點擊這里下載
安裝下載好的 VCForPython27.msi 一路next 就好
同時也需要安裝 pywin32
下載地址
安裝下載好的pywin32一路next 就好
這些都安裝好了之后,繼續(xù)通過命令行安裝lxml,但是可能會因為網(wǎng)速的原因,這種方式依然安裝的很慢,那么我們只能通過直接下載安裝包的方式來安裝
lxml下載地址:點擊 根據(jù)操作系統(tǒng)選擇不同的版本(32位或者64位的)
安裝下載好的lxml程序一路next 就好
安裝scrapy
pip install scrapy現(xiàn)在可能遇到這樣的錯誤ImportError DLL load failed: %1 不是有效的 Win32 應(yīng)用程序
是由于安裝的32位的 MySQL-Python-1.2.3.win32-py2.exe,,只要改成64位版本的就可以了或者是你本身是64位的操作系統(tǒng)然后安裝了32位的python
如果是 MySQL-Python安裝錯誤,直接更改它的版本就行,如果是python 版本錯誤,那么需要重新安裝上面的步驟
MySQL-Python可以使用如下鏈接下載:
32位:http://download.csdn.net/detail/seven_zhao/6607621
64位:http://download.csdn,net/detail/seven_zhao/6607625
也可以在如下地址下載:
http://www.codegood.com/downloads
新聞熱點
疑難解答