Bit of backstory, I'm relatively new to Python and development in general and have stupidly been installing project specific packages as system packages. This is now causing me issues when trying to create requirements.txt files for specific projects, inside of virtualenvs.
For example, I've installed Kivy system wide and every time I create a new env with a requirements file I'm getting the below (yes the env is active):
$ pip freeze > requirements.txt
$ cat requirements.txt
Kivy==1.9.1
Pillow==2.6.1
Pygments==2.0.1
chardet==2.3.0
colorama==0.3.2
docutils==0.12
html5lib==0.999
kazam==1.4.5
pygobject==3.14.0
python-apt==0.9.3.12
python-debian==0.1.27
pyxdg==0.25
requests==2.4.3
roman==2.0.0
six==1.8.0
urllib3==1.9.1
wheel==0.24.0
I've also tried uninstalling Kivy, amongst other things (trying to be cautious here, don't want to remove vital OS packages) but get the following output:
$ pip uninstall kivy
Not uninstalling Kivy at /usr/lib/python3/dist-packages, owned by OS
So my questions is this: How can I get my python packages back to default, with only the essential system packages installed (almost like a fresh python install), then how do I prevent the requirements.txt files inside of a virtualenv including the system wide installed packages (I'll be using evn's much better in future so shouldn't have too many system wide packages)
I'd also be interested to find out why pip unistall kivy
doesnt work (yes, I've tried running this as root also)
Running Debian 8, if that makes any difference
Hope this makes sense and appreciate any advise you may have.
EDIT: So I think I've been doing this whole thing wrong, once I've created the env I've been using pip install
rather than env/bin/pip install
. Unless I'm mistaken this is why the packages have been installing globally. Same goes for the requirements file.
You can freeze just your local packages in each virtualenv by using the -l
(or --local
) parameter
pip freeze --local > requirements.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With