pip卸载正常但是出现

2024-04-29 13:34:06 发布

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

我已经下载、构建并安装了示例pypi项目。该项目应该用于深入了解python打包,并在Python Packaging User Guide和{a2}中引用。因此,我很困惑,为什么按照他们的指示创建包,我在卸载时会出错。在

如上所述,我使用了他们的示例项目。如果有人能提供一些启示,我们将不胜感激。在

关键提示:我运行的是macosx,我安装的python版本是3.5.1 以下是重现问题的步骤:

mkdir testdirectory 
cd testdirectory/
pyvenv venv    # Creating a virtual environment
source venv/bin/activate
git clone https://github.com/pypa/sampleproject.git    # Getting sample project
cd sampleproject/
python setup.py build
python setup.py install    # Installing on the virtual environment

pip list
peppercorn (0.5)
pip (7.1.2)
sample (1.2.0)
setuptools (18.2)

pip uninstall sample

产生以下输出:

^{pr2}$

包已正确卸载,但仍会引发错误。在


Tags: pipsample项目pygitsampleprojectpypi示例
2条回答

安装包时不要使用python setup.py install,而要使用pip install .

然后卸载将不会出错

记录如下:

$ pip help uninstall

Usage:
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

Description:
  Uninstall packages.

  pip is able to uninstall most installed packages. Known exceptions are:

  - Pure distutils packages installed with ``python setup.py install``, which
    leave behind no metadata to determine what files were installed.
  - Script wrappers installed by ``python setup.py develop``.

也就是说,您得到错误是因为您没有使用pip本身来安装-您使用了setup.py,所以pip不知道安装了什么。在

相关问题 更多 >