删除安装在开发模式下的 python 模块

我使用 setuptools 尝试了 Python 打包,为了测试,我在开发模式下安装了该模块。 也就是说

python setup.py develop

这将我的 module 目录添加到 sys.path。现在我要移除模块。有什么办法吗?

26342 次浏览

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.

Edit easy-install.pth in your site-packages directory and remove the line that points to your development version of that package.

Use the --uninstall or -u option to develop, i.e:

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).