ImportError: No module named pip

2019-01-16 15:30发布

OS: Mac OS X 10.7.5 Python Ver: 2.7.5

I have installed setuptools 1.0 with ez_setup.py from https://pypi.python.org/pypi/setuptools Then I download pip.1.4.1 pkg from https://pypi.python.org/pypi/pip/1.4.1.

Run "[sudo]python setup.py install" in iTerm shows that

running install running bdist_egg running egg_info writing requirements to pip.egg-info/requires.txt writing pip.egg-info/PKG-INFO writing top-level names to pip.egg-info/top_level.txt writing dependency_links to pip.egg-info/dependency_links.txt writing entry points to pip.egg-info/entry_points.txt warning: manifest_maker: standard file 'setup.py' not found

reading manifest file 'pip.egg-info/SOURCES.txt' writing manifest file 'pip.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.6-intel/egg running install_lib warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build/bdist.macosx-10.6-intel/egg creating build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/PKG-INFO -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/entry_points.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/not-zip-safe -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/requires.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO copying pip.egg-info/top_level.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO creating 'dist/pip-1.4.1-py2.7.egg' and adding 'build/bdist.macosx-10.6-intel/egg' to it removing 'build/bdist.macosx-10.6-intel/egg' (and everything under it) Processing pip-1.4.1-py2.7.egg removing '/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg' (and everything under it) creating /Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg Extracting pip-1.4.1-py2.7.egg to /Users/dl/Library/Python/2.7/lib/python/site-packages pip 1.4.1 is already the active version in easy-install.pth Installing pip script to /Users/dl/Library/Python/2.7/bin Installing pip-2.7 script to /Users/dl/Library/Python/2.7/bin

Installed /Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg Processing dependencies for pip==1.4.1 Finished processing dependencies for pip==1.4.1

Then I inputed "pip install", the error message showed like that

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 9, in load_entry_point('pip==1.4.1', 'console_scripts', 'pip')() File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 357, in load_entry_point File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2394, in load_entry_point File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2108, in load ImportError: No module named pip

Anyone who met the same problem before and can give me some tips to solve it?

标签: python pip
10条回答
小情绪 Triste *
2楼-- · 2019-01-16 15:56

I had the same problem. My solution:

For Python 3

sudo apt-get install python3-pip

For Python 2

sudo apt-get install python-pip
查看更多
Juvenile、少年°
3楼-- · 2019-01-16 15:57

In terminal try this:

ls -lA /usr/local/bin | grep pip

in my case i get:

-rwxr-xr-x 1 root  root      284 Сен 13 16:20 pip
-rwxr-xr-x 1 root  root      204 Окт 27 16:37 pip2
-rwxr-xr-x 1 root  root      204 Окт 27 16:37 pip2.7
-rwxr-xr-x 1 root  root      292 Сен 13 16:20 pip-3.4

So pip2 || pip2.7 in my case works, and pip

查看更多
姐就是有狂的资本
4楼-- · 2019-01-16 16:00

I downloaded pip binaries from here and it resolved the issue.

查看更多
该账号已被封号
5楼-- · 2019-01-16 16:03

I think none of these answers above can fix your problem.

I was also confused by this problem once. You should manually install pip following the official guide pip installation (which currently involves running a single get-pip.py Python script)

after that, just sudo pip install Django. The error will be gone.

查看更多
对你真心纯属浪费
6楼-- · 2019-01-16 16:07

On Mac using brew is a better option as apt-get is not available. Command:

In case you have both python2 & python3 installed on machine

python2.7 -m ensurepip --default-pip

simply should solve the issue.

If instead you are missing pip from python 3 then simply change python2.7 to python3 in the command above.

查看更多
Luminary・发光体
7楼-- · 2019-01-16 16:08

I ran into this same issue when I attempted to install the nova client.

spencers-macbook-pro:python-novaclient root# python  setup.py install    
running install
/usr/bin/python: No module named pip
error: /usr/bin/python -m pip.__init__ install   'pbr>=0.5.21,<1.0' 'iso8601>=0.1.4' 'PrettyTable>=0.6,<0.8' 'requests>=1.1' 'simplejson>=2.0.9' 'six' 'Babel>=0.9.6' returned 1

I use homebrew so I worked around the issue with sudo easy_install pip

spencers-macbook-pro:python-novaclient root# brew search pip
aespipe     brew-pip    lesspipe    pipebench   pipemeter   spiped  pipeviewer

If you meant "pip" precisely:

Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
    sudo easy_install pip
spencers-macbook-pro:python-novaclient root# sudo easy_install pip

The commands should be similar if you use macports.

查看更多
登录 后发表回答