I recently installed the Anaconda version of Python. Now when I type python
into the terminal it opens the Anaconda distribution rather than the default distribution. How do I get it to use the default version for the command python
on Linux (Ubuntu 12.04 (Precise Pangolin))?
You can use conda without Anaconda, but using Anaconda always involves the conda tool. module load python/3.4. x-anaconda Python 3 is the latest version of the language and python 2 is considered legacy. Generally you should choose Python 3 for new projects whenever possible.
Anaconda supports Python 3.7, 3.8, 3.9 and 3.10. The current default is Python 3.9.
Installing the Anaconda platform will install the following: Python; specifically the CPython interpreter that we discussed in the previous section. A number of useful Python packages, like matplotlib, NumPy, and SciPy. Jupyter, which provides an interactive “notebook” environment for prototyping code.
Anaconda is popular because it brings many of the tools used in data science and machine learning with just one install, so it's great for having short and simple setup. Like Virtualenv, Anaconda also uses the concept of creating environments so as to isolate different libraries and versions.
Anaconda adds the path to your .bashrc
, 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.
You can also use the full path /usr/bin/python
in Bash to use the default Python interpreter.
If you leave your .bashrc
file as is, any command you run using python
will use the Anaconda interpreter. If you want, you could also use an alias
for each interpreter.
You will see something like export PATH=$HOME/anaconda/bin:$PATH
in your .bashrc
file.
So basically, if you want to use Anaconda as your main everyday interpreter, use the full path to your default Python or create an alias
. If you want it the other way around, remove the export PATH=...
. from bashrc
and use full path to Anaconda Python interpreter.
Having tried all the suggestions so far, I think modifying the export statement in file ~/.bashrc, as Piotr Dobrogost seems to suggest, is the best option considering the following:
So in 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With