2012-11-10 114 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。