python setup.py卸载 [英] python setup.py uninstall

查看:68
本文介绍了python setup.py卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用 python setup.py install 安装了一个 python 包.

如何卸载它?

解决方案

注意:避免使用 python setup.py install 使用 pip install .

您需要手动删除所有文件,并撤消安装手动完成的任何其他操作.

如果您不知道所有文件的列表,您可以使用 --record 选项重新安装它,然后查看生成的列表.

要记录已安装文件的列表,您可以使用:

python setup.py install --record files.txt

一旦您想卸载,您可以使用 xargs 进行删除:

xargs rm -rf <文件.txt

或者,如果您运行的是 Windows,请使用 Powershell:

Get-Content files.txt |ForEach-Object {Remove-Item $_ -Recurse -Force}

然后删除包含目录,例如/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/my_module-0.1.egg/macOS 上.它没有文件,但 Python 仍然会导入一个空模块:

<预><代码>>>>导入 my_module>>>my_module.__file__没有任何

删除后,Python 显示:

<预><代码>>>>导入 my_module回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中ModuleNotFoundError: 没有名为my_module"的模块

I have installed a python package with python setup.py install.

How do I uninstall it?

解决方案

Note: Avoid using python setup.py install use pip install .

You need to remove all files manually, and also undo any other stuff that installation did manually.

If you don't know the list of all files, you can reinstall it with the --record option, and take a look at the list this produces.

To record a list of installed files, you can use:

python setup.py install --record files.txt

Once you want to uninstall you can use xargs to do the removal:

xargs rm -rf < files.txt

Or if you're running Windows, use Powershell:

Get-Content files.txt | ForEach-Object {Remove-Item $_ -Recurse -Force}

Then delete also the containing directory, e.g. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/my_module-0.1.egg/ on macOS. It has no files, but Python will still import an empty module:

>>> import my_module
>>> my_module.__file__
None

Once deleted, Python shows:

>>> import my_module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'my_module'

这篇关于python setup.py卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆