102

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?

7
  • 4
    Start using pip or other manager with uninstall ability for managing python packages. Commented Aug 31, 2010 at 6:54
  • 1
    @Tomasz How do you do the equivalent of python setup.py develop with pip? Commented Dec 29, 2011 at 9:28
  • 7
    pip install -e . Commented Dec 29, 2011 at 11:22
  • 11
    'pip' is not the right answer to this question. Installing a project you are developing using 'pip' in order to run or use it means you'll have to reinstall every time you modify the source code. The correct way is the use 'setup.py develop' as the original question states. Commented Jun 29, 2012 at 11:25
  • 6
    @JonathanHartley That's just plain false; pip has an --editable (or -e) argument that behaves roughly equivalently to setuptools' develop. I thought that perhaps --editable was newer than your comment, but nope - a quick search of the pip repo on GitHub turns up references to editables in commits back in 2009. What's more, I see that this was already pointed out by Tomasz Wysocki before you commented! Commented Jan 7, 2018 at 12:37

3 Answers 3

236

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

Sign up to request clarification or add additional context in comments.

6 Comments

Note that if your development version installed some executables, and you changed them in your setup.py, you should manually remove them.
I run it just as explained, no errors in the output, yet I'm still able to import my development package globally, it seems it hasn't been removed. EDIT: I know why, I had to run it with --user option as I did during the installation: python setup.py develop --uninstall --user
I don't think this is safe as things can change in develop (for example) renaming the module. You need to manually remove everything.
@norok2 what are the manual commands one has to run to remove those executables. As far as I know the above works for certain version of python/pip though I'm not sure which ones.
@CharlieParker rm or del depending on your OS. What I meant is that if you had some executables at the time you installed and then change their names (or remove them) in your setup.py, then setup.py will not know about them any longer (no matter your pip / python version and you need to take care of them manually. They are usually located in some bin directory on POSIX (read Linuxes, BSDs, MacOS X) systems, can't remember about Win.
|
18

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

3 Comments

Yeah i did exactly this and one more file was there by name package-egg-link or something which I removed and now reference to the module is removed Thanks :)
"setup.py develop --uninstall" does this for you, see @pjeby's answer
This worked for me when develop --uninstall failed because I had split a project into two, and the wrong one remained in the original directory.
1

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.

1 Comment

Well from next time I play with packages I will use this so I won't screw up my system Python. Thanks for the info

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.