how to install package with pypi in python 2.7?

末鹿安然 提交于 2019-12-11 02:17:18

问题


this problem, I have when try install package netstat with pypi

[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...

and other question: how to install packages in python2.7 and not in 3?


回答1:


While Kugel's answer is perfectly valid, I would also urge you to avoid system wide install, and to use a virtualenv. It will allow you to create a sandbox for your project and isolate it from others.

When creating a virtualenv, you can specify the Python interpreter version you want to use. For example, for python2.7:

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

Then, a pip install command will automatically install the package for python2.7.




回答2:


  1. The package you mention is corrupted / incomplete. Download source code from here and you can see there is only setup.py and no other source code. Beside that, the homepage is a broken link.

  2. To install for a different version of python use pip-2.7 install xxx. There is usually a pip-x.y for each python version you have installed.



来源:https://stackoverflow.com/questions/13319591/how-to-install-package-with-pypi-in-python-2-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!