操作系统:Mac OS X 10.7.5 Python版本:2.7.5

我已经从https://pypi.python.org/pypi/setuptools用ez_setup.py安装了setuptools 1.0 然后我从https://pypi.python.org/pypi/pip/1.4.1下载pip.1.4.1 pkg。

在iTerm中运行(sudo) python setup.py install即可显示

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

谁以前遇到过同样的问题,能给我一些解决方法吗?


当前回答

我只需要用pip3替换pip,所以我最终运行如下命令

其他回答

我认为以上这些答案都不能解决你的问题。

我也曾被这个问题困扰过。您应该按照pip安装的官方指南(目前涉及运行一个get-pip.py Python脚本)手动安装pip。

之后,只需sudo pip安装Django。 错误就会消失。

尝试通过Python安装pip:

请登录:https://pip.pypa.io/en/stable/installation/

下载get-pip.py,然后运行:

(sudo) python get-pip.py

当我使用命令创建一个新的Python 3虚拟环境时,我遇到了ModuleNotFoundError: No module named 'pip'的问题

python3 -m venv ~/venv/ontology    ## << note: "python3" (problematic)

这是一个经常被建议的命令(这里,其他地方)。当我走进那家酒馆时,皮普已经不见了。

在此期间,自从第一次使用该命令创建Python虚拟环境以来,我的系统Python已经从Python 3.7.4升级到Python 3.9.2。

解决方案是使用命令

python -m venv <your_venv>  ## e.g. python -m ~/venv/ontology

当我这样做(python -m…不是python3 -m…),venv现在包含PIP…

要在venv中升级pip,请使用

<your_venv_path>/bin/python -m pip install --upgrade pip

## e.g.
## /home/victoria/venv/ontology/bin/python -m pip install --upgrade pip

Python -m ensurepip——user

这如果你的MAC不是以上大sur

你安装了py 3 -

我做到了,现在没有问题了

回到2.7的遗留版本。

Windows:

python -m ensurepip

激活你的env ex: venv后

(venv) PS D:\your path> d:\your path\venv\scripts\python.exe -m pip install --upgrade pip

结果样本:

收集皮普

使用缓存的pip-21.3-py3-none-any。whl (1.7 MB)

安装收集包:pip

尝试卸载:pip

Found existing installation: pip 20.1.1

Uninstalling pip-20.1.1:

  Successfully uninstalled pip-20.1.1

成功安装pip-21.3