0
votes

I am running Ubuntu 19.10 on my laptop, I recently installed miniconda3. No problems this far, but after creating an environment with python 2.7 I get the following message every time I open a terminal:

Command 'python' not found, but can be installed with:
sudo apt install python3         # version 3.7.5-1, or
sudo apt install python          # version 2.7.17-1
sudo apt install python-minimal  # version 2.7.17-1

So I followed the advise and installed python, then this error occured:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
ImportError: No module named conda

My guess is that bash is trying to access the conda python 2.7? Here is what I get by running which python without conda active:

which python

/usr/bin/python

which python3

/usr/bin/python3

whereis python

python: /usr/bin/python2.7 /usr/bin/python3.7 /usr/bin/python3.7m /usr/bin/python /usr/lib/python3.8 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python2.7 /etc/python3.7 /etc/python /usr/local/lib/python2.7 /usr/local/lib/python3.7 /usr/include/python3.7m /usr/share/python /usr/share/man/man1/python.1.gz

with conda activated here are the corresponding results:

which python

/home/rustax/miniconda3/bin/python

which python3

/home/rustax/miniconda3/bin/python3

whereis python

python: /usr/bin/python2.7 /usr/bin/python3.7 /usr/bin/python3.7m /usr/bin/python /usr/lib/python3.8 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python2.7 /etc/python3.7 /etc/python /usr/local/lib/python2.7 /usr/local/lib/python3.7 /usr/include/python3.7m /usr/share/python /home/rustax/miniconda3/bin/python3.7-config /home/rustax/miniconda3/bin/python3.7m /home/rustax/miniconda3/bin/python3.7 /home/rustax/miniconda3/bin/python3.7m-config /home/rustax/miniconda3/bin/python /usr/share/man/man1/python.1.gz

I tried creating a symbolic link from /home/rustax/miniconda3/bin/python to /usr/bin/python but the same error appeared.

Conda adds the following lines to .bashrc:

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

Thank you in advance for any help you can provide

1
You said that this error happened after you created a new conda environment. How did you create that env?orangeInk
conda create -n myenv python=2 But I checked and it's not only after creating an environment. It also happens after updating a fresh conda install. I updated with the following command: conda update --allrustax
Please edit your question to show the commands you ran to create the env, how you activated the env, and how you try to run Python.merv
Sorry for all the fuss but I have solved the problem. :P Quite a simple one tbh.rustax

1 Answers

0
votes

Sorry for all the fuss but I have solved the problem. Since Ubuntu 19.10 doesn't come with python2 pre-installed what I did to get rid of the problem was to first remove python (since I installed it after installing conda, note that this is python and not python3 since python3 comes pre-installed) and conda completely with the following lines.

sudo apt-get purge --auto-remove python

rm -rf ~/miniconda3

rm -rf ~/.condarc ~/.conda ~/.continuum

After this I installed python

sudo apt install python

And after installing python I installed conda the normal way and now I don't get any of the error messages posted when I open up a terminal. I guess order of PATH variables matters. Since when I had troubles I first installed conda and followed up by installing python and think that condas python path might have come first.