How to reset anaconda root environment
See https://github.com/conda/conda/issues/1032
This has been implemented as
conda list --revisions
andconda install --rev REV_NUM
.
EDIT: be careful though if you execute conda install --rev 0
as this will remove your root environment and the conda
command. Maybe conda install --rev 1
would produce the desired behavior (restore root environment to its state after first installation).
EDIT 2018-03-07: Use the --revision
argument instead of --rev
Revert Anaconda like the first time installed
Specific Answers
- Does
conda remove -n env_name --all
delete the environment and all its installed packages under its environment too? Or does it only delete the environment?
It will delete environment my_env, which includes the unpacked libraries and the env/env_name
directory. It will not delete the cached tarballs in the conda/pkgs
directory.
- Can I delete directly folder
pkgs
andenv
from Users/user without affect the base environment?
You shouldn't do this because Conda may be using hard or soft links to share packages across environments, and hence it can be difficult to determine what you may affect by such blunt deletion. If you wish to delete an environment, you should use the command in (1). If you wish to delete cached packages, you should use conda clean
(use --help
flag to see the options available).
- How can one revert Anaconda like the first time installed (contain only base environment and the default packages)?
Again, you can delete the other envs with conda remove --all
. For base, you can revert it to the original state with
conda install -n base --revision 0
However, I will note that many users report this not working.
General RecommendationMiniconda
Since you seem like you want a clean break, I'd recommend the complete uninstall of Anaconda. However, since you appear primarily concerned with space, instead of reinstalling Anaconda, consider switching to Miniconda, which only includes the Conda package manager and minimal infrastructure to support it. Then create envs that only include the packages that you actually require. You can still use conda clean --tarballs
to minimize cached downloads, but already with Miniconda you should have a significantly smaller footprint than the full Anaconda distribution.
Managing Environments
As a general rule of thumb, I recommend using base only for installing infrastructure (Jupyter, git, emacs, etc.) and using separate environments for the specific package environments you need (e.g., TensorFlow, PyTorch). In my experience, this helps to keep your base more stable, and allows you to partition off potential package conflicts and wrap up specific projects by clearing out envs after you no longer need them.
clean the base environment in Anaconda
There's not a slick and safe one-liner to do this. You can uninstall things one-by-one, but that is tedious and risks accidentally uninstalling something you need. Having extra stuff installed in your base environment shouldn't be much of a problem; it's fine to just leave stuff there.
Related Topics
How to Remove Square Brackets from List in Python
Add N Empty Rows in a Dataframe
Efficient Way of Having a Function Only Execute Once in a Loop
Making a Matrix in Python 3 Without Numpy Using Inputs
Pandas Counting and Summing Specific Conditions
Python - Having Trouble Opening a File With Spaces
Python Pandas: Drop Rows of a Timeserie Based on Time Range
Pytest Cannot Import Module While Python Can
Pyspark Regexp_Replace With List Elements Are Not Replacing the String
What Is the Fastest Way to Stack Numpy Arrays in a Loop
How to Normalize a Numpy Array to Within a Certain Range
How to Select All Elements Greater Than a Given Values in a Dataframe
Return Value from Python-Shell as Response
How to Remove Empty Cell from Data Frame Row Wise
How to Open a Password Protected Excel File Using Python
Convert a Tensor to Numpy Array in Tensorflow
How to Remove the Double Quote When the Value Is Empty in Spark