Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python2.7中使用pypi安装软件包?_Python_Pypi - Fatal编程技术网

如何在Python2.7中使用pypi安装软件包?

如何在Python2.7中使用pypi安装软件包?,python,pypi,Python,Pypi,这个问题,我在尝试用pypi安装netstat包时遇到过 [opmeitle@localhost ~]$ 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 Instal

这个问题,我在尝试用pypi安装netstat包时遇到过

[opmeitle@localhost ~]$ 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而不是pytho3中安装软件包

  • 您提到的软件包已损坏/不完整。从下载源代码,您可以看到只有setup.py,没有其他源代码。除此之外,主页是一个断开的链接

  • 要安装不同版本的python,请使用
    pip-2.7安装xxx
    。对于您安装的每个python版本,通常都有一个pip-x.y

  • 虽然这是完全正确的,但我也建议您避免在系统范围内安装,并使用。 它将允许您为您的项目创建一个沙箱,并将其与其他项目隔离开来

    创建virtualenv时,可以指定要使用的Python解释器版本。例如,对于python2.7:

    $ virtualenv path/to/project -p /usr/bin/python2.7
    
    然后,一个
    pip install
    命令将自动安装python2.7的包