如何 pip 卸载使用 git 项目 URL 安装的包?
How to pip uninstall a package installed using a git project URL?
我尝试按照 BlueJeans 会议 REST API (https://github.com/bluejeans/api-rest-meetings/tree/master/libs/python) 的安装说明进行操作,使用命令
pip install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
pip freeze
命令确认我已经安装了它:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip freeze
BlueJeansMeetingsRestApi==1.0.0
certifi==2018.4.16
python-dateutil==2.7.3
six==1.11.0
urllib3==1.23
但是,在 iPython shell 中,我无法导入 BlueJeansMeetingsRestApi
:
Kurts-MacBook-Pro-2:~ kurtpeek$ ipython
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import BlueJeansMeetingsRestApi
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-0891de0c20ce> in <module>()
----> 1 import BlueJeansMeetingsRestApi
ModuleNotFoundError: No module named 'BlueJeansMeetingsRestApi'
这是在我的本地环境中,但我也将其安装在 Pipenv 环境中,在这种情况下,我需要提供一个鸡蛋,我通过将 #egg=BlueJeansMeetingsRestApi
附加到Git 项目 URL。如果我直接这样做,我会得到 'requirement already satisfied':
Kurts-MacBook-Pro-2:~ kurtpeek$ pip install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo#egg=BlueJeansMeetingsRestApi
Requirement already satisfied: BlueJeansMeetingsRestApi from git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo#egg=BlueJeansMeetingsRestApi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.0.0)
Requirement already satisfied: urllib3>=1.15 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (1.23)
Requirement already satisfied: six>=1.10 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (1.11.0)
Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (2018.4.16)
Requirement already satisfied: python-dateutil in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (2.7.3)
因此,我想尝试先卸载 BlueJeans 并 re-install 它指定了 egg。但是,如果我尝试用同一个项目 URL 卸载它,我会收到以下错误:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip uninstall git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
You must give at least one requirement to uninstall (see "pip help uninstall")
顺便说一下,我使用的是 Python 3.7.0(pip
是 pip3
的别名)。
我有两个问题:
- 为什么
import BlueJeansMeetingsRestApi
一开始就不起作用?
- 如何卸载它?
要卸载软件包只需使用
pip uninstall BlueJeansMeetingsRestApi
如果 IPYTHON 存在一些配置问题,您可能会遇到此类错误。
但是如果你 运行 时间紧迫,我建议直接使用 python shell 命令 shell 获取,我认为这应该适用于你尝试将其导入文件。
python <filename>.py
请检查并告诉我。
总结 CoderRambo and tgikal 的回复,是的,我能够以这种方式卸载 BlueJeansMeetingsRestApi
:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip uninstall BlueJeansMeetingsRestApi
Uninstalling BlueJeansMeetingsRestApi-1.0.0:
Would remove:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/BlueJeansMeetingsRestApi-1.0.0-py3.7.egg-info
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/BlueJeansMeetingsRestApi/*
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/test/*
Proceed (y/n)? y
Successfully uninstalled BlueJeansMeetingsRestApi-1.0.0
然而,问题的根源在于 iPython 在 Python 3.6 上是 运行,而 BlueJeans 安装在 Python 3.7 上。我使用 which ipython
:
确认了这一点
Kurts-MacBook-Pro-2:~ kurtpeek$ which ipython
/Library/Frameworks/Python.framework/Versions/3.6/bin/ipython
I 运行 pip install ipython
,现在指向Python 3.7:
Kurts-MacBook-Pro-2:~ kurtpeek$ which ipython
/Library/Frameworks/Python.framework/Versions/3.7/bin/ipython
然后我重新安装了 BlueJeans REST API(没有指定 egg),现在我可以导入它了:
Kurts-MacBook-Pro-2:~ kurtpeek$ ipython
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import BlueJeansMeetingsRestApi
In [2]:
我尝试按照 BlueJeans 会议 REST API (https://github.com/bluejeans/api-rest-meetings/tree/master/libs/python) 的安装说明进行操作,使用命令
pip install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
pip freeze
命令确认我已经安装了它:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip freeze
BlueJeansMeetingsRestApi==1.0.0
certifi==2018.4.16
python-dateutil==2.7.3
six==1.11.0
urllib3==1.23
但是,在 iPython shell 中,我无法导入 BlueJeansMeetingsRestApi
:
Kurts-MacBook-Pro-2:~ kurtpeek$ ipython
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import BlueJeansMeetingsRestApi
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-0891de0c20ce> in <module>()
----> 1 import BlueJeansMeetingsRestApi
ModuleNotFoundError: No module named 'BlueJeansMeetingsRestApi'
这是在我的本地环境中,但我也将其安装在 Pipenv 环境中,在这种情况下,我需要提供一个鸡蛋,我通过将 #egg=BlueJeansMeetingsRestApi
附加到Git 项目 URL。如果我直接这样做,我会得到 'requirement already satisfied':
Kurts-MacBook-Pro-2:~ kurtpeek$ pip install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo#egg=BlueJeansMeetingsRestApi
Requirement already satisfied: BlueJeansMeetingsRestApi from git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo#egg=BlueJeansMeetingsRestApi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.0.0)
Requirement already satisfied: urllib3>=1.15 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (1.23)
Requirement already satisfied: six>=1.10 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (1.11.0)
Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (2018.4.16)
Requirement already satisfied: python-dateutil in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from BlueJeansMeetingsRestApi) (2.7.3)
因此,我想尝试先卸载 BlueJeans 并 re-install 它指定了 egg。但是,如果我尝试用同一个项目 URL 卸载它,我会收到以下错误:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip uninstall git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
You must give at least one requirement to uninstall (see "pip help uninstall")
顺便说一下,我使用的是 Python 3.7.0(pip
是 pip3
的别名)。
我有两个问题:
- 为什么
import BlueJeansMeetingsRestApi
一开始就不起作用? - 如何卸载它?
要卸载软件包只需使用
pip uninstall BlueJeansMeetingsRestApi
如果 IPYTHON 存在一些配置问题,您可能会遇到此类错误。
但是如果你 运行 时间紧迫,我建议直接使用 python shell 命令 shell 获取,我认为这应该适用于你尝试将其导入文件。
python <filename>.py
请检查并告诉我。
总结 CoderRambo and tgikal 的回复,是的,我能够以这种方式卸载 BlueJeansMeetingsRestApi
:
Kurts-MacBook-Pro-2:~ kurtpeek$ pip uninstall BlueJeansMeetingsRestApi
Uninstalling BlueJeansMeetingsRestApi-1.0.0:
Would remove:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/BlueJeansMeetingsRestApi-1.0.0-py3.7.egg-info
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/BlueJeansMeetingsRestApi/*
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/test/*
Proceed (y/n)? y
Successfully uninstalled BlueJeansMeetingsRestApi-1.0.0
然而,问题的根源在于 iPython 在 Python 3.6 上是 运行,而 BlueJeans 安装在 Python 3.7 上。我使用 which ipython
:
Kurts-MacBook-Pro-2:~ kurtpeek$ which ipython
/Library/Frameworks/Python.framework/Versions/3.6/bin/ipython
I 运行 pip install ipython
,现在指向Python 3.7:
Kurts-MacBook-Pro-2:~ kurtpeek$ which ipython
/Library/Frameworks/Python.framework/Versions/3.7/bin/ipython
然后我重新安装了 BlueJeans REST API(没有指定 egg),现在我可以导入它了:
Kurts-MacBook-Pro-2:~ kurtpeek$ ipython
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import BlueJeansMeetingsRestApi
In [2]: