2012-11-10 112 views
2

這個問題,我有當嘗試安裝包的netstat在PyPI如何在python 2.7中安裝pypi包?

[[email protected] ~]$ sudo pip install netstat 
[sudo] password for opmeitle: 

Downloading/unpacking netstat 
    Running setup.py egg_info for package netstat 

    file nester_g:.py (for module nester_g:) not found 
Installing collected packages: netstat 
    Running setup.py install for netstat 
    file nester_g:.py (for module nester_g:) not found 
    file nester_g:.py (for module nester_g:) not found 
    warning: install_lib: 'build/lib' does not exist -- no Python modules to install 


    file nester_g:.py (for module nester_g:) not found 
    file nester_g:.py (for module nester_g:) not found 
Successfully installed netstat 
Cleaning up... 

和其他問題:如何安裝軟件包在python2.7,而不是在3?

回答

2
  1. 您提到的軟件包已損壞/不完整。從here下載源代碼,你可以看到只有setup.py,沒有其他的源代碼。除此之外,主頁是一個斷開的鏈接。

  2. 要安裝不同版本的python,請使用pip-2.7 install xxx。對於您安裝的每個python版本,通常都會有一個pip-x.y。

3

雖然Kugel's answer是完全有效的,我也勸你,以避免全系統安裝和使用virtualenv。 它可以讓你爲你的項目創建一個沙箱,並將其與其他人隔離。

創建virtualenv時,可以指定要使用的Python解釋器版本。例如,對於python2.7:

$ virtualenv path/to/project -p /usr/bin/python2.7 

然後,pip install命令將自動安裝包python2.7。