How to Change Default Anaconda Python Environment

How to change default Anaconda python environment

If you just want to temporarily change to another environment, use

source activate environment-name

ETA: This may be deprecated. I believe the current correct command is:

source conda activate environment-name

(you can create environment-name with conda create)


To change permanently, there is no method except creating a startup script that runs the above code.


Typically it's best to just create new environments. However, if you really want to change the Python version in the default environment, you can do so as follows:

First, make sure you have the latest version of conda by running

conda update conda

Then run

conda install python=3.5

This will attempt to update all your packages in your root environment to Python 3 versions. If it is not possible (e.g., because some package is not built for Python 3.5), it will give you an error message indicating which package(s) caused the issue.

If you installed packages with pip, you'll have to reinstall them.

change default environment from (base) to (env) in conda/anaconda in Ubuntu

Currently there does not seem to be a "default environment" setting for conda, but I think you can get the behaviour you want with nested activation of conda environments, or "stacked" environments.

You can either do this explicitly or implicitly by changing the conda config. Both assumes that you already have (env) activated somehow (either manually or adding it to .bashrc).

  • Explicitly: conda activate --stack new_env. The next time you do conda deactivate, this should take you back to your previous environment rather than (base).

  • Implicitly:

    • conda config --set auto_stack 5 (should be greater than 0, it is how many nested levels you want)
    • Now if you do conda activate new_env, then it behaves as if it was called as conda activate --stack new_env.

If you don't care about the base environment at all, you can disable automatic activation of it by conda config --set auto_activate_base false.

The --stack option has been available since conda 4.6.0.

How to change default Anaconda python environment

If you just want to temporarily change to another environment, use

source activate environment-name

ETA: This may be deprecated. I believe the current correct command is:

source conda activate environment-name

(you can create environment-name with conda create)


To change permanently, there is no method except creating a startup script that runs the above code.


Typically it's best to just create new environments. However, if you really want to change the Python version in the default environment, you can do so as follows:

First, make sure you have the latest version of conda by running

conda update conda

Then run

conda install python=3.5

This will attempt to update all your packages in your root environment to Python 3 versions. If it is not possible (e.g., because some package is not built for Python 3.5), it will give you an error message indicating which package(s) caused the issue.

If you installed packages with pip, you'll have to reinstall them.

How to change Python version of existing conda virtual environment?

Activate the relevant environment, then install your target python version.

conda activate my_env
conda install python=3.6

How to change python version in Anaconda?

A better (recommended) alternative is to create a virtual environment of the desired Python version and then use that environment to run Tensorflow and other scripts.

To do that, you can follow the instructions given here.

BUT, if you don't want to create a separate environment, then conda install python=<version> should do.

OR (not recommended) you can download the "latest" Anaconda installer with your required Python version bundled.

Source



Related Topics



Leave a reply



Submit