问题:ImportError:没有名为pip的模块
操作系统:Mac OS X 10.7.5 Python Ver:2.7.5
我已经安装了setuptools的1.0 ez_setup.py从https://pypi.python.org/pypi/setuptools 然后我下载pip.1.4.1 PKG从https://pypi.python.org/pypi/pip/1.4.1。
python setup.py install
在iTerm中运行(sudo)显示
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
然后我输入pip install
,错误信息显示为
Traceback (most recent call last): File
"/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 9,
in <module>
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
曾经遇到过相同问题并且可以给我一些解决方法的人吗?
回答 0
我有同样的问题。我的解决方案:
对于Python 3
sudo apt-get install python3-pip
对于Python 2
sudo apt-get install python-pip
回答 1
在Mac上,使用brew是一个更好的选择,因为apt-get不可用。命令:
如果您在机器上同时安装了python2和python3
python2.7 -m ensurepip --default-pip
根本应该解决问题。
相反,如果您缺少python 3的pip,则只需在上述命令中更改python2.7
为即可python3
。
回答 2
安装ez_setup之后,您应该已经easy_install
可以使用。要安装pip
只需执行以下操作:
easy_install pip
回答 3
使用macOS 10.15和Homebrew 2.1.6时,Python 3.7出现此错误。我只需要运行:
python3 -m ensurepip
现在python3 -m pip
为我工作。
回答 4
尝试pip
通过Python 安装:
请转到:https : //pip.pypa.io/en/stable/installing/
并下载get-pip.py
,然后运行:
(sudo) python get-pip.py
回答 5
尝试安装nova客户端时,我遇到了同样的问题。
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
我使用自制软件,因此我解决了 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
如果使用macports,则命令应类似。
回答 6
我认为上述所有答案都无法解决您的问题。
我曾经也被这个问题弄糊涂了。您应该pip
按照官方指南pip安装(当前涉及运行单个get-pip.py
Python脚本)进行手动安装
之后,就sudo pip install Django
。错误将消失。
回答 7
我知道这个线程很旧,但是我在OS X上为自己解决了这个问题,与这里描述的有所不同。
基本上,我是通过brew重新安装了Python 2.7的,它附带了pip。
如果尚未安装Xcode,请安装:
xcode-select –install
为说明安装啤酒在这里:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后通过Brew安装Python:
brew install python
这样就完成了。就我而言,我只需要安装pyserial。
pip install pyserial
回答 8
我pip
从这里下载了二进制文件,它解决了这个问题。
回答 9
在终端中尝试以下操作:
ls -lA /usr/local/bin | grep pip
就我而言:
-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
所以pip2 || 在我的情况下pip2.7可以正常工作,并且pip
回答 10
我的Py版本是3.7.3,这个cmd有效
python3.7 -m pip install requests
请求库-用于从Web API检索数据。
这将运行pip模块,并要求其在PyPI.org(Python软件包索引)上找到请求库,并将其安装在本地系统中,以便您可以导入
回答 11
通过在站点软件包位置设置PYTHONPATH,我解决了Linux上的类似错误。这是在跑步之后python get-pip.py --prefix /home/chet/pip
。
[chet@rhel1 ~]$ ~/pip/bin/pip -V
Traceback (most recent call last):
File "/home/chet/pip/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
[chet@rhel1 ~]$ export PYTHONPATH=/home/chet/pip/lib/python2.6/site-packages
[chet@rhel1 ~]$ ~/pip/bin/pip -V
pip 9.0.1 from /home/chet/pip/lib/python2.6/site-packages (python 2.6)
回答 12
在Linux下进行了以下测试:您可以直接从https://pypi.org/simple/pip/ untar 下载pip,并直接与最新的python一起使用。
tar -xvf pip-0.2.tar.gz
cd pip-0.2
检查内容。
anant$ ls
docs pip.egg-info pip-log.txt pip.py PKG-INFO regen-docs scripts setup.cfg setup.py tests
直接执行:
anant$ python pip.py --help
Usage: pip.py COMMAND [OPTIONS]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-E DIR, --environment=DIR
virtualenv environment to run pip in (either give the
interpreter or the environment base directory)
-v, --verbose Give more output
-q, --quiet Give less output
--log=FILENAME Log file where a complete (maximum verbosity) record
will be kept
--proxy=PROXY Specify a proxy in the form
user:passwd@proxy.server:port. Note that the
user:password@ is optional and required only if you
are behind an authenticated proxy. If you provide
user@proxy.server:port then you will be prompted for a
password.
--timeout=SECONDS Set the socket timeout (default 15 seconds)
回答 13
以下是使用MacPorts升级到Python 3的最少说明:
sudo port install py37-pip
sudo port select --set pip pip37
sudo port select --set pip3 pip37
sudo pip install numpy, scipy, matplotlib
我运行了一些旧代码,在升级后它又可以工作了。
回答 14
按照该URL的建议进行操作,以重命名python39._pth文件。那解决了问题
ren python39._pth python39._pth.save
回答 15
在诸如ubuntu之类的linux上,首先执行apt-get update,然后尝试安装python-pip软件包。如果没有apt-get更新,您可能会收到如下错误:
E:无法找到软件包python-pip
1.更新
sudo apt-get update
2,安装pip包
对于python2
sudo apt-get install python-pip
要么
对于python3
sudo apt-get install python3-pip
并做了!