天天看點

python Win7下搭建

包括Python,eclipse,jdk,pydev,pip,setuptools,beautifulsoup,pyyaml,nltk,mysqldb的下載下傳安裝配置。

*************************************************

W

下載下傳:

python-2.7.6.amd64.msi

<a target="_blank" href="http://www.python.org/">http://www.python.org/</a>

Python 2.7.6 released

Python 2.7.6 is now available.

<a target="_blank" href="http://www.python.org/download/releases/2.7.6/">http://www.python.org/download/releases/2.7.6/</a>

Windows X86-64 MSI Installer (2.7.6) [1] (sig)

安裝

配置:

我的電腦-&gt;屬性-&gt;進階-&gt;環境變量-&gt;系統變量中的PATH增加:C:\Python27;

驗證:

在桌面建立一個檔案pt.py,内容為print 'hello python'

在cmd中輸入指令python C:\Users\***\Desktop\pt.py

***為電腦使用者名。

C:\Users\***&gt;python C:\Users\***\Desktop\pt.py

hello python

C:\Users\***&gt;

Eclipse:

eclipse-java-indigo-SR2-win32-x86_64.zip

<a target="_blank" href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a>

Older Versions

<a target="_blank" href="http://wiki.eclipse.org/Older_Versions_Of_Eclipse">http://wiki.eclipse.org/Older_Versions_Of_Eclipse</a>

Eclipse Indigo SR2 Packages (v 3.7.2)

<a target="_blank" href="http://www.eclipse.org/downloads/packages/release/indigo/sr2">http://www.eclipse.org/downloads/packages/release/indigo/sr2</a>

Eclipse IDE for Java Developers, (128 MB)

Downloaded 1,226,421 TimesDetails Windows 32-bit  64-bit 

<a target="_blank" href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/indigo/SR2/eclipse-java-indigo-SR2-win32-x86_64.zip">http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/indigo/SR2/eclipse-java-indigo-SR2-win32-x86_64.zip</a>

Download eclipse-java-indigo-SR2-win32-x86_64.zip from:

jdk:

jdk-7u45-windows-x64.exe

<a target="_blank" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a>

Windows x64 125.31 MB     jdk-7u45-windows-x64.exe

<a target="_blank" href="http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html">http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html</a>

pydev

為了在Eclipse中進行python工程的開發。

<a target="_blank" href="http://sourceforge.net/projects/pydev/files/">http://sourceforge.net/projects/pydev/files/</a>

版本一直在更新中,幾天前是3.1.0.zip

下載下傳完,解壓縮,将features和plugins檔案夾中的内容分别複制到eclipse的features和plugins檔案夾下。

重複則替換。

具體方法見windows xp,32位,環境下,Eclipse+python平台搭建

pip

<a target="_blank" href="https://pypi.python.org/pypi/pip">https://pypi.python.org/pypi/pip</a>

Download

解壓縮,在cmd中進入到pip-1.4.1目錄,執行 python setup.py install

報錯:

ImportError: No module named setuptools

是以,需要先安裝setuptools

setuptools

<a target="_blank" href="https://pypi.python.org/pypi/setuptools/">https://pypi.python.org/pypi/setuptools/</a>

setuptools 2.0.2

點選右側Downloads按鈕,跳至Downloads

Scroll to the very bottom of the page to find the links.

需要到頁面底部去找連結下載下傳。

File Type Py Version Uploaded on Size

setuptools-2.0.2-py2.py3-none-any.whl (md5)  Python Wheel  3.4 2013-12-29 527KB

setuptools-2.0.2.tar.gz (md5)  Source  2013-12-29 765KB

下載下傳setuptools-2.0.2.tar.gz (md5)

解壓縮

在cmd中進入到setuptools-2.0.2目錄,執行 python setup.py install

成功标志:

Installed c:\python27\lib\site-packages\setuptools-2.0.2-py2.7.egg

Processing dependencies for setuptools==2.0.2

Finished processing dependencies for setuptools==2.0.2

繼續安裝pip

在cmd中進入到pip-1.4.1目錄,執行 python setup.py install

成功标記:

Installed c:\python27\lib\site-packages\pip-1.4.1-py2.7.egg

Processing dependencies for pip==1.4.1

Finished processing dependencies for pip==1.4.1

添加到系統環境變量Path:C:\Python27\Scripts;

在cmd測試,輸入pip,輸出:

C:\Users\***&gt;pip

Usage:

  pip [options]

Commands:

  install                     Install packages.

  uninstall                   Uninstall packages.

  freeze                      Output installed packages in requirements format.

  list                        List installed packages.

  show                        Show information about installed packages.

  search                      Search PyPI for packages.

  wheel                       Build wheels from your requirements.

  zip                         Zip individual packages.

  unzip                       Unzip individual packages.

  bundle                      Create pybundles.

  help                        Show help for commands.

BeautifulSoup

可以利用pip進行安裝:

在cmd中敲入指令查找BeautifulSoup:

C:\Users\***&gt;pip search BeautifulSoup

BeautifulSoup             - HTML/XML parser for quick-turnaround applications

                            like screen-scraping.

pynliner                  - Python CSS-to-inline-styles conversion tool for

                            HTML using BeautifulSoup and cssutils

Detextile                 - Convert HTML to Textile syntax using

                            BeautifulSoup.

TreeSoup                  - BeautifulSoup-like wrapper around ElementTree.

beautifulscraper          - Python web-scraping library that wraps urllib2 and

ElementSoup               - ElementTree wrapper for BeautifulSoup HTML parser

beautifulsoup4            - Screen-scraping library

collective.soupstrainer   - Clean up HTML using BeautifulSoup and filter

                            rules.

在cmd中敲入指令安裝BeautifulSoup

C:\Users\***&gt;pip install BeautifulSoup

Downloading/unpacking BeautifulSoup

  Downloading BeautifulSoup-3.2.1.tar.gz

  Running setup.py egg_info for package BeautifulSoup

Installing collected packages: BeautifulSoup

  Running setup.py install for BeautifulSoup

Successfully installed BeautifulSoup

Cleaning up...

還可參見:安裝Beautiful Soup

PyYAML 

可以利用pip進行安裝

C:\Users\***&gt;pip search pyyaml

PyYAML                    - YAML parser and emitter for Python

pyaml                     - PyYAML-based module to produce pretty and readable

                            YAML-serialized data

yamly                     - pyyaml wrapper

enhancedyaml              - It makes it more convenient to use PyYAML.

C:\Users\***&gt;pip install PyYAML

Downloading/unpacking PyYAML

  Downloading PyYAML-3.10.tar.gz (241kB): 241kB downloaded

  Running setup.py egg_info for package PyYAML

Installing collected packages: PyYAML

  Running setup.py install for PyYAML

    checking if libyaml is compilable

    Unable to find vcvarsall.bat

    skipping build_ext

Successfully installed PyYAML

nltk

<a target="_blank" href="https://pypi.python.org/pypi/nltk/">https://pypi.python.org/pypi/nltk/</a>

nltk 2.0.4

nltk-2.0.4.tar.gz (md5)  Source  2012-11-07 933KB

nltk-2.0.4.win32.exe (md5)  MS Windows installer  2.5 2012-11-07 1MB

nltk-2.0.4.zip (md5)  Source  2012-11-07 1MB

下載下傳nltk-2.0.4.tar.gz

解壓縮,在cmd中進入到nltk-2.0.4目錄,執行 python setup.py install

Installed c:\python27\lib\site-packages\nltk-2.0.4-py2.7.egg

Processing dependencies for nltk==2.0.4

Searching for PyYAML==3.10

Best match: PyYAML 3.10

Adding PyYAML 3.10 to easy-install.pth file

Using c:\python27\lib\site-packages

Finished processing dependencies for nltk==2.0.4

打開python Idle:

輸入import nltk

輸入nltk.download()

出現一個NLTK Downloader對話框,修改Download Diretory(E盤或其他盤符下)。點選all開始下載下傳。

重裝系統後nltk_data檔案夾可以保留,避免重複下載下傳。

mysqldb

<a target="_blank" href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python">http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python</a>

MySQL-python-1.2.4.win-amd64-py2.7.exe

直接輕按兩下安裝。

成功驗證:

py檔案:

import MySQLdb

connection = MySQLdb.connect(host="127.0.0.1",user="root",passwd="root",db="dbtest")

cursor = connection.cursor()

cursor.execute( "SELECT id,content FROM tabletest  ")

print "Rows selected:", cursor.rowcount

運作結果輸出dbtest資料庫中tabletest表的行數。