Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change installed Python module in virtualenv

I have a module installed using pip in a virtualenv. I want to experiment with a single change on one line of its code, and wonder if it will work by going straight to the source file and changing that line?

If not, what is the easiest way to do so? Download the source, change it, and run python setup.py install inside the virtualenv? But would that install the module inside the virtualenv? And can I still remove it later using pip or I need to clean it up manually?

like image 820
skyork Avatar asked Oct 06 '22 21:10

skyork


1 Answers

As long as the module you wish to edit is written in pure Python, changing the source code in the virtualenv's site-packages directory should work just fine. If the module is a C-extension, then you will need to recompile the module before the changes take effect.

Edit: Note that if you are working with the module in an interactive session, you will need to reload the module in the session (and re-instantiate any object instances based on that module) each time you make a change.

like image 158
Brendan Wood Avatar answered Oct 10 '22 01:10

Brendan Wood