close

How to change default Anaconda python environment

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to change default Anaconda python environment in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to change default Anaconda python environment?

  1. How to change default Anaconda python environment?

    If you just want to temporarily change to another environment, use
    source activate environment-name

  2. change default Anaconda python environment

    If you just want to temporarily change to another environment, use
    source activate environment-name

Method 1

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.

Method 2

Under Linux there is an easier way to set the default environment by modifying ~/.bashrc or ~/.bash_profile At the end you’ll find something like

# added by Anaconda 2.1.0 installer
export PATH="~/anaconda/bin:$PATH"

Replace it with

# set python3 as default
export PATH="~/anaconda/envs/python3/bin:$PATH"

and thats all there is to it.

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read