Windows 下 Python easy_install 的安裝


下載安裝python安裝工具
下載地址:http://pypi.python.org/pypi/setuptools 可以找到正確的版本進行下載。win7 32位可以下載setuptools-0.6c11.win32-py2.7.exe 。


注意:win7 64位必須使用ez_setup.py進行安裝。方法是下載ez_setup.py后,在cmd下執行 python ez_setup.py,即可自動安裝setuptools。目前沒有直接的exe安裝版本。

注意2:更新了更簡單的辦法,可以直接跳轉到最后面

下載完成后雙擊執行安裝文件,即可在D:\Program Files\python2.7\scripts下安裝easy_install。包含一個easy_install.exe,然后進行環境變量設置,在系統環境變量中做如下設置:
(也就是將D:\Program Files\python2.7\scripts添加到環境變量中)
 

 
此時可以在控制台看easy_install 是否安裝上了。
 
Microsoft Windows [版本 6.1.7600]
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。

C:\Users\zhuyupeng>easy_install
error: No urls, filenames, or requirements specified (see --help)
 
上面這種方式不正確,需要使用下面的方式:

C:\Users\zhuyupeng>easy_install virtualenv
Searching for virtualenv
Best match: virtualenv 1.7.2
Processing virtualenv-1.7.2-py2.7.egg
virtualenv 1.7.2 is already the active version in easy-install.pth
Installing virtualenv-script.py script to D:\Program Files\Python2.7\Scripts
Installing virtualenv.exe script to D:\Program Files\Python2.7\Scripts
Installing virtualenv.exe.manifest script to D:\Program Files\Python2.7\Scripts
Installing virtualenv-2.7-script.py script to D:\Program Files\Python2.7\Scripts

Installing virtualenv-2.7.exe script to D:\Program Files\Python2.7\Scripts
Installing virtualenv-2.7.exe.manifest script to D:\Program Files\Python2.7\Scri
pts

Using d:\program files\python2.7\lib\site-packages\virtualenv-1.7.2-py2.7.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

安裝lxml:
C:\Users\zhuyupeng>
 
 
如果直接使用:
easy_install lxml 
 
        
C:\Users\zhuyupeng> easy_install lxml 則會出現下面問題:
ERROR:‘xslt-config’ 不是內部或外部命令
make sure the developing packages of libxml2 and libxslt are installed windows
 
 
 
可以使用安裝.egg 文件的方式來安裝:
網站上下載對應的lxml .egg 文件
然后使用下面的方式來安裝:
C:\Users\zhuyupeng> easy_install D:\Program Files\Python2.7\lxml-2.3.py2.7.win32.egg
 
注:對於*.exe 文件這樣也可以安裝
 
通過這樣的方式就可以安裝成功了:
可以通過在控制台輸入:easy_install lxml 來查看:
 
Microsoft Windows [版本 6.1.7600]
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。

C:\Users\zhuyupeng>easy_install lxml
Searching for lxml
Best match: lxml 2.3.4
Adding lxml 2.3.4 to easy-install.pth file

Using d:\program files\python2.7\lib\site-packages
Processing dependencies for lxml
Finished processing dependencies for lxml

C:\Users\zhuyupeng>
 
 
安裝了easy_install 之后安裝python的庫就很簡單了,以后需要安裝python的庫的話則直接在命令行使用
easy_install + libname
 
比如:

C:\Users\zhuyupeng>easy_install numpy
Searching for numpy
...
Processing dependencies for numpy
Finished processing dependencies for numpy


這是下載下來再安裝的:
C:\Users\zhuyupeng>easy_install "D:\Program Files\Python2.7\matplotlib-1.1.0.win
32-py2.7.exe"
...
Processing dependencies for matplotlib==1.1.0
Finished processing dependencies for matplotlib==1.1.0

C:\Users\zhuyupeng>
 
 
附一個畫愛心的程序:
"""
'17*x^2 - 16*|x|*y + 17*y^2 = 225'
"""

import numpy as np
import matplotlib.pyplot as plt

X = np.arange(-5.0, 5.0, 0.1)
Y = np.arange(-5.0, 5.0, 0.1)

x, y = np.meshgrid(X, Y)
f = 17 * x ** 2 - 16 * np.abs(x) * y + 17 * y ** 2 - 225

fig = plt.figure()
cs = plt.contour(x, y, f, 0, colors = 'r')
plt.show()

 

 

20:00 2013-12-19

更簡單的辦法,只需要輸入幾個命令就ok了:

以下是在IDLE中進行的:

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from urllib import urlopen
>>> data = urlopen('http://peak.telecommunity.com/dist/ez_setup.py')
>>> open('ez_setup.py','wb').write(data.read())
>>> exit
Use exit() or Ctrl-Z plus Return to exit
>>>

//++++++++++++++++++++++++++++++++++++++++++++++ 分割線 +++++++++++++++++++++++++++++

以下是在windows控制台進行的:

D:\ProgramFile\Python2.7>python ez_setup.py
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-p
y2.7.egg
Processing setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to d:\programfile\python2.7\lib\site-package
s
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install-script.py script to D:\ProgramFile\Python2.7\Scripts
Installing easy_install.exe script to D:\ProgramFile\Python2.7\Scripts
Installing easy_install.exe.manifest script to D:\ProgramFile\Python2.7\Scripts
Installing easy_install-2.7-script.py script to D:\ProgramFile\Python2.7\Scripts

Installing easy_install-2.7.exe script to D:\ProgramFile\Python2.7\Scripts
Installing easy_install-2.7.exe.manifest script to D:\ProgramFile\Python2.7\Scri
pts

Installed d:\programfile\python2.7\lib\site-packages\setuptools-0.6c11-py2.7.egg

Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

總共只需要5個命令:IDLE中4個,windows控制台中1個

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM