Reputation: 1
Im working on a 16in MacBook Pro and only rely on basic python3 with pip. How to go about cleaning things up so that I only with the necessities I can build up my environments again quickly as at this point I only have a Django and flask Env set up and don't mind recreating them.
My virtual environments previously had vary few things in them, my projects current don't require to much but at the end of a long day I started exploring API's and thought I had activated a new environment that created moments before just to contain any new packages. A few days later when attempting to update some models from Python shell i was faced with an error asking me to check my Django project settings but after much trouble shooting we discovered it was the that I didn't activate the environment when installing the packages.
I so far plan on just pip uninstalling one by one, but I don't want to remove the wrong thing and have much work to complete after undoing what broke.
asgiref 3.2.7 astroid 2.4.1 autopep8 1.5.3 bcrypt 3.1.7 cffi 1.14.0 click 7.1.2 cssselect 1.1.0 d 0.2.2 Django 3.0.8 Flask 1.1.2 isort 4.3.21 itsdangerous 1.1.0 Jinja2 2.11.2 lazy-object-proxy 1.4.3 lxml 4.5.1 Markdown 3.2.2 MarkupSafe 1.1.1 mccabe 0.6.1 pip 20.1.1 pycodestyle 2.6.0 pycparser 2.20 Pygments 2.6.1 pylint 2.5.2 pyquery 1.4.1 pytz 2020.1 setuptools 41.2.0 six 1.15.0 sqlparse 0.3.1 toml 0.10.1 Werkzeug 1.0.1 wrapt 1.12.1
Upvotes: 0
Views: 13747
Reputation: 22438
You could use a tool like pipdeptree or deptree to help you figure out what project is a dependency of which, and thus help you decide which ones you want to remove and which ones you want to keep.
But it might be easier to start with a fresh virtual environment and install only the things you need in a clean environment.
Upvotes: 1
Reputation: 605
Follow the below steps
Just make a list of the packages you want to remove.
save it in the txt file.
use below command
pip uninstall -r file_name.txt
If you want to remove all the packages except builtins. Use below steps
Run the below commands in your environment
pip freeze > dependencies.txt
Uninstall using below command
pip uninstall -r dependencies.txt
Upvotes: 3