If you want to completely remove all Conda environments, Conda itself, and all pip-installed packages from your WSL2 Ubuntu, follow these steps carefully.
-
Check where Conda is installed (usually in ~/anaconda3 or ~/miniconda3):
This will give you a path like /home/your-user/miniconda3/bin/conda.
-
Remove the entire Conda directory:
rm -rf ~/anaconda3 ~/miniconda3 ~/.conda
-
Remove Conda from your shell profile:
sed -i '/conda initialize/,/fi/d' ~/.bashrc ~/.zshrc
-
Verify Conda is gone:
If it still shows up, restart your terminal or run:
If you have multiple environments, list them:
Then remove them all:
conda env remove --name my_env
But since we already deleted Conda, manually delete the environments:
-
Uninstall all pip packages:
pip freeze | xargs pip uninstall -y
-
Remove system-wide pip packages:
sudo rm -rf /usr/local/lib/python*/dist-packages/*
-
Delete user-installed pip packages:
rm -rf ~/.local/lib/python*
-
Remove pip cache:
If you want a completely fresh Python setup, you can remove and reinstall Python:
-
Check Python version:
-
Uninstall Python:
sudo apt remove --purge python3
-
Reinstall Python (if needed):
sudo apt update && sudo apt install python3 python3-pip -y
Run these commands to free up space and ensure all traces of Conda and Pip are gone:
rm -rf ~/.bash_history ~/.zsh_history
Then restart WSL:
Reopen your WSL and verify Conda and Pip are fully removed.
After this, your system should be completely free of Conda and Pip packages, giving you a fresh start. 🚀 Let me know if you run into any issues!