Coder Perfect

When calling Python from the terminal, use the default Python installation rather than the Anaconda installation.


I recently installed the Python Anaconda distribution. Instead of the default distribution, when I put python into the terminal, it now launches the Anaconda distribution. On Linux (Ubuntu 12.04 (Precise Pangolin)), how can I get it to utilize the default version of the command python?

Asked by Michael

Solution #1

The path is added to your.bashrc by Anaconda, so it is found first. You can add the path to your default Python instance to .bashrc or remove the path to Anaconda if you don’t want to use it.

To utilize the default Python interpreter in Bash, use the entire path /usr/bin/python.

If you leave your.bashrc file alone, the Anaconda interpreter will be used for all python commands. You could also use an alias for each interpreter if you like.

In your.bashrc file, you’ll find something like export PATH=$HOME/anaconda/bin:$PATH.

So, if you want to utilize Anaconda as your primary Python interpreter, either enter the complete path to your default Python or create an alias for it. Remove the export PATH=…. from bashrc and use the complete path to the Anaconda Python interpreter if you want it the other way around.

Answered by Padraic Cunningham

Solution #2

After trying all of the suggestions so far, I believe that changing the export statement in file /.bashrc, as Piotr Dobrogost appears to suggest, is the best option, given the following:

As a result, in the file /.bashrc, instead of

# Added by the Anaconda3 4.3.0 installer
export PATH="/home/user/anaconda3/bin:$PATH"

one would use

export PATH="$PATH:/home/user/anaconda3/bin"

Answered by Asta86

Solution #3

I had the same problem, and here’s what I did.

In your.bashrc file, you’ll find a line that looks like this:

export PATH=~/anaconda3/bin:$PATH

You remove the comment and replace it with:

alias pyconda='~/anaconda3/bin/python3'

Or whatever road you’ve chosen. This worked out perfectly for me.

Answered by Pulkit Gera

Solution #4

It acted differently in 2020, as @spacetyper mentioned. From this question, I’ve discovered a useful solution: How can I prevent Conda from automatically activating the basic environment?

To turn off automatic base activation, follow these steps.

conda config --set auto_activate_base false

After the initial run, it will create a./condarc in the home directory.

Answered by user1896653

Solution #5

Conda inserts a more sophisticated block of code to the bottom of your.bash profile file in the year 2020, which looks something like this:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/spacetyper/opt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
    if [ -f "/Users/spacetyper/opt/miniconda3/etc/profile.d/" ]; then
        . "/Users/spacetyper/opt/miniconda3/etc/profile.d/"
        export PATH="/Users/spacetyper/opt/miniconda3/bin:$PATH"
unset __conda_setup
# <<< conda initialize <<<

To utilize the default Python installation, follow these steps: Simply move this code section to the top of your.bash profile file.

To give oneself the option of using the Python that Conda has installed, do the following: Below the Conda code block, add this line.

alias pyconda="/Users/spacetyper/opt/miniconda3/bin/python3"

You should now be able to use python to install Python on the system and pyconda to install Conda.

Answered by spacetyper

Post is based on