无法更新pip3,即使我尝试更新

2024-04-26 06:49:27 发布

您现在位置:Python中文网/ 问答频道 /正文

总之,我似乎进入了一个循环,pip认为我使用的是过时的pip版本,但当我试图升级它时,不允许我使用。所以我尝试安装(从这个问题Jupyter Notebook can't find modules for python 3.6):

(automl) brandomiranda~ ❯ pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)
Requirement not upgraded as not directly required: jupyter-client in /usr/local/lib/python3.6/site-packages (from ipykernel) (5.3.4)
Requirement not upgraded as not directly required: traitlets>=4.1.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (4.3.3)
Requirement not upgraded as not directly required: appnope; platform_system == "Darwin" in /usr/local/lib/python3.6/site-packages (from ipykernel) (0.1.0)
Requirement not upgraded as not directly required: tornado>=4.2 in /usr/local/lib/python3.6/site-packages (from ipykernel) (6.0.3)
Requirement not upgraded as not directly required: ipython>=5.0.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (7.11.1)
Requirement not upgraded as not directly required: jupyter-core>=4.6.0 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (4.6.1)
Requirement not upgraded as not directly required: pyzmq>=13 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (18.1.1)
Requirement not upgraded as not directly required: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (2.8.1)
Requirement not upgraded as not directly required: six in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (1.11.0)
Requirement not upgraded as not directly required: ipython-genutils in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (0.2.0)
Requirement not upgraded as not directly required: decorator in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (4.4.1)
Requirement not upgraded as not directly required: backcall in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.1.0)
Requirement not upgraded as not directly required: pickleshare in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.7.5)
Requirement not upgraded as not directly required: pexpect; sys_platform != "win32" in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (4.7.0)
Requirement not upgraded as not directly required: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (3.0.2)
Requirement not upgraded as not directly required: jedi>=0.10 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.15.2)
Requirement not upgraded as not directly required: pygments in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (2.5.2)
Requirement not upgraded as not directly required: setuptools>=18.5 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (39.0.1)
Requirement not upgraded as not directly required: ptyprocess>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect; sys_platform != "win32"->ipython>=5.0.0->ipykernel) (0.6.0)
Requirement not upgraded as not directly required: wcwidth in /usr/local/lib/python3.6/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.0.0->ipykernel) (0.1.8)
Requirement not upgraded as not directly required: parso>=0.5.2 in /usr/local/lib/python3.6/site-packages (from jedi>=0.10->ipython>=5.0.0->ipykernel) (0.5.2)
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed kernelspec python3 in /Users/brandomiranda/Library/Jupyter/kernels/python3

好吧,我会升级,但它认为已经升级了:

^{pr2}$

但当我再次尝试安装时,它失败了,并显示了相同的消息。这似乎是一个鸡和蛋的问题。有人知道怎么回事吗?在


过时的:

我最近做了一个pip3 list来检查我在虚拟环境中安装了哪些模块/项目,并得到了升级pip的建议。我试过了,但似乎无法更新/升级。我做到了:

$ pip3 list
namespaces (4.2.0)
pip (8.0.2)
scikit-learn (0.18.1)
setuptools (19.4)
six (1.10.0)
wheel (0.26.0)
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

所以我试着这么做,它说它是有效的:

$ pip install --upgrade pip
Requirement already up-to-date: pip in /Users/user/home_simulation_research/hbf_tensorflow_code/venv/lib/python2.7/site-packages

因为它说它一直在那里,我又做了一次pip3列表,它一直说我实际上没有升级它。由于使用标准pip命令进行更新不起作用,因此我尝试使用pip3进行更新,但仍然不起作用:

pip3 install --upgrade pip3
Collecting pip3
  Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

为什么不管用?在


就在我觉得没用的时候,我试着用pip3升级pip,用pip3升级pip3。由于某些原因,后者似乎不起作用,但第一个有效。i、 e.做:

$ pip3 install --upgrade pip

工作(或至少pip3 list)停止请求我升级。为什么?只是我,还是这真的很奇怪?在


Tags: pipinfromlibpackagesusrlocalas
3条回答

当您运行pip3 list时,您正在列出为python3安装的包,当您运行pip install upgrade pip时,您正在检查python2包的更新。当您运行pip3 install upgrade pip3时,会出现一个错误,因为没有名为pip3的包,pip3是pip包中提供的命令行工具。当您最后运行pip3 install upgrade pip时,您做的是正确的(安装python3的更新,包名为pip)。在

如果您注意到站点包路径的不同,您将得到它。在

当您使用pip3时,/usr/local/lib/python3.6/site-packages路径显示为python3.6。在

参考号:

(automl) brandomiranda~ ❯ pip3 install ipykernel  upgrade
python3 -m ipykernel install  user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)

当你只使用pip时,你会看到它是python3.7和完全不同的站点包路径./miniconda3/envs/automl/lib/python3.7/site-packages

参考号:

^{pr2}$

所以两者都是不同的:pip3指向的是Python3.6的直接系统路径(/usr/local/libdocs),而pip指向安装Python3.7的虚拟环境路径(./miniconda3/envs/automl/lib/)。在

你需要决定升级和使用哪一个。拥有虚拟环境是最佳实践。在

对我有用的是卸载并安装pip。在

要卸载pip,请执行以下操作:

pip uninstall pip

尽管我去了/usr/local/bin,删除了所有带有pip name的内容:

^{pr2}$

有一些pip3的东西仍然很奇怪。在

然后我用sudo easy install安装pip(已弃用):

sudo easy_install pip

虽然这个命令被弃用了,所以必须在mac上做一些其他的事情,但目前还可以(并且使我的jupyter笔记本再次工作,从而解决了这个问题Jupyter Notebook can't find modules for python 3.6)。在

相关问题 更多 >