删除在开发模式下安装的python模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3606457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing python module installed in develop mode
提问by copyninja
Hi I was trying the python packaging using setuptools and to test I installed the module in develop mode. i.e
嗨,我正在尝试使用 setuptools 打包 python 并测试我在开发模式下安装的模块。IE
python setup.py develop
This has added my modules directory to sys.path. Now I want to remove the module is there any way to do this?
这已将我的模块目录添加到 sys.path。现在我想删除模块有什么办法吗?
Thanks in advance
提前致谢
采纳答案by PJ Eby
Use the --uninstallor -uoption to develop, i.e:
使用--uninstall或-u选项develop,即:
python setup.py develop --uninstall
This will remove it from easy-install.pth and delete the .egg-link. The only thing it doesn't do is delete scripts (yet).
这将从 easy-install.pth 中删除它并删除 .egg-link。它唯一不做的就是删除脚本(还)。
回答by Tanerax
I have had a similar problem to this before. What I did was I loaded up the Python shell, imported the module and then printed its __file__attribute. From there I would just remove the folder or file that was being associated.
我之前也遇到过类似的问题。我所做的是加载 Python shell,导入模块,然后打印其__file__属性。从那里我将删除正在关联的文件夹或文件。
What you may want to look into is using virtualenvthis system allows you to create a instance of python separate from your system. Any modules you install or use in this instance are self contained including the version of the module.
您可能想要研究的是使用virtualenv这个系统允许您创建一个与您的系统分开的 python 实例。您在此实例中安装或使用的任何模块都是自包含的,包括模块的版本。
I keep all my projects now inside of there own contained virtualenv, which allows me to install and use whatever modules I want without worrying about screwing up modules from other projects.
我现在将所有项目都保存在自己包含的 virtualenv 中,这使我可以安装和使用我想要的任何模块,而不必担心搞砸其他项目中的模块。
回答by Zooko
Edit easy-install.pth in your site-packages directory and remove the line that points to your development version of that package.
编辑 site-packages 目录中的 easy-install.pth 并删除指向该包的开发版本的行。

