删除在开发模式下安装的python模块
我正在尝试使用 setuptools 进行 python 打包并测试我在开发模式下安装了该模块。 即
python setup.py develop
这已将我的模块目录添加到 sys.path 中。现在我想删除该模块。有什么办法可以做到这一点吗?
I was trying the python packaging using setuptools and to test I installed the module in develop mode.
i.e
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
--uninstall
或-u
选项来develop
,即:这将从easy-install.pth中删除它并删除.egg -关联。它唯一不做的就是删除脚本(还)。
Use the
--uninstall
or-u
option todevelop
, i.e:This will remove it from easy-install.pth and delete the .egg-link. The only thing it doesn't do is delete scripts (yet).
编辑 site-packages 目录中的 easy-install.pth 并删除指向该包的开发版本的行。
Edit easy-install.pth in your site-packages directory and remove the line that points to your development version of that package.
我以前也遇到过类似的问题。我所做的是加载 Python shell,导入模块,然后打印它的 __file__ 属性。从那里我只需删除关联的文件夹或文件。
你可能想要研究的是使用 virtualenv 这个系统允许你创建一个 python 实例与您的系统分开。您在此实例中安装或使用的任何模块都是独立的,包括模块的版本。
我现在将所有项目保存在自己包含的 virtualenv 中,这使我可以安装和使用我想要的任何模块,而不必担心搞砸其他项目的模块。
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.What you may want to look into is using virtualenv this 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.
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.