操作系统: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

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


当我试图安装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,命令应该类似。


我从这里下载了pip二进制文件,它解决了这个问题。


在终端试试这个:

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


在安装ez_setup之后,您应该拥有可用的easy_install。安装pip只需执行以下操作:

easy_install pip

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

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

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


我也有同样的问题。 我的解决方案:

对于Python 3

sudo apt-get install python3-pip

对于Python 2

sudo apt-get install python-pip

我知道这个线程是旧的,但我只是在OS X上为自己解决了不同于这里描述的问题。

基本上,我通过brew重新安装了Python 2.7,它附带了pip。

如果还没有安装Xcode:

xcode-select –install

按照下面的描述安装Brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后通过Brew安装Python:

brew install python

做完了。在我的情况下,我只需要安装pyserial。

pip install pyserial

在Mac上使用brew是一个更好的选择,因为apt-get不可用。 命令:

brew install python

如果你的机器上同时安装了python2和python3

python2.7 -m ensurepip --default-pip

应该简单地解决这个问题。

如果相反,你从python3中缺少pip,那么只需在上面的命令中将python2.7更改为python3。


我在Linux上通过将PYTHONPATH设置为site-packages位置解决了一个类似的错误。这是在运行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)

尝试通过Python安装pip:

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

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

(sudo) python get-pip.py

我的py版本是3.7.3,这个CMD可以工作

Python3.7 -m PIP安装请求

请求库-用于从web api检索数据。

这将运行pip模块,并要求它在PyPI.org (Python包索引)上找到请求库,并将其安装到您的本地系统中,以便您可以导入它


在macOS 10.15和Homebrew 2.1.6中,我在Python 3.7中得到这个错误。我只需要运行:

python3 -m ensurepip

现在python3 -m pip为我工作。


Linux测试如下: 您可以直接从https://pypi.org/simple/pip/下载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)

下面是使用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

我运行了一些旧代码,它在这次升级后再次工作。


按照这个URL的建议,重命名python39。_pth文件。这就解决了问题

https://michlstechblog.info/blog/python-install-python-with-pip-on-windows-by-the-embeddable-zip-file/#more-5606

ren python39._pth python39._pth.save

在某种Linux上,比如基于Debian的发行版,你可能会考虑先更新你的“apt-get”,以防你通过它安装python-pip。

sudo apt-get update

这可能有助于apt-get更新其索引并定位python-pip包。 在此之后,u可能会像这样安装pip -

sudo apt-get install python-pip (Python2)
sudo apt-get install python3-pip (Python3)

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


我在virtualenv中遇到了类似的问题,在从requirements.txt文件安装依赖项时使用了python3.8。我设法让它工作通过激活virtualenv,然后运行命令python -m pip install -r requirements.txt,它工作。


Run

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

然后在下载的文件夹中执行以下命令:get-pip.py

python get-pip.py

我在MacOS Big Sur上使用Python 3.8.6时遇到了同样的错误。

无论我使用pip还是pip3,我都会得到这个错误:

 File "/Users/marcelloromani/dev/<repository>/venv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'

原来我的virtualenv已经过时了。 这解决了我的问题:

删除旧的virtualenv

$ deactivate
$ rm -rf venv

初始化一个新的virtualenv

$ virtualenv venv
$ . venv/bin/activate

安装新的要求,然后工作:

$ pip install -r src/requirements.txt

Windows:

如果下载Python时没有pip:执行该命令

python get-pip.py


下载:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

然后安装pip:

py get-pip.py

然后安装生物马拉松:

py -m pip install biopython

我希望它会有用


当我使用命令创建一个新的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

试着重新安装pip 使用curl命令下载get-pip.py文件:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

如果curl不起作用,那么打开这个链接: get-pip.py

在您的目录中创建get-pip.py文件 从该链接复制代码,并将其放入get-pip.py文件中,并将该文件保存在同一目录中。 然后运行命令

python get-pip.py

我正在使用Debian,但是这个解决方案也可以应用于Ubuntu。

通常,pip默认带有python,以便检查系统运行中是否安装了pip。

Python -m PIP——version

如果pip不存在,使用Aptitude Linux包管理器安装它,

# For Python 2 Sudo安装python-pip # For Python 3 Sudo安装python3-venv python3-pip

我不会在Debian/Ubuntu中使用get-pip.py脚本,因为在文档页面中提到了以下内容。

如果您使用的Python安装由您的操作系统或其他包管理器管理,请谨慎。py与这些工具不协调,可能使您的系统处于不一致的状态。

到处都有消息来源。


如果你在ubuntu中得到“没有名为pip的模块”,试试这个。

$python3 -m pip --version
/usr/bin/python3: No module named pip

$sudo apt-get install python3-pip

这对我很管用。

安装成功后验证使用

$python3 -m pip --version

升级到最新的pip版本

$python3 -m pip install --upgrade pip

执行sudo apt-get install PIP后重试该进程 这解决了我的问题


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


对于python2.7,请从https://bootstrap.pypa.io/pip/2.7/get-pip.py下载

然后运行

python get-pip.py

Python -m ensurepip——user

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

你安装了py 3 -

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

回到2.7的遗留版本。


我在win11上也遇到了同样的错误,所以主要问题是在没有管理权限的情况下执行pip命令,所以使用管理员权限打开终端,然后再次执行pip命令。希望能有所帮助,