Why does "which python" return nothing?
Looking at what you've shown, I guess there are at least two issues.
First, your path is incorrect. You shouldn't set your path to "/usr/bin/python3.6". I think that's an executable. You should set your path to "/usr/bin/" (which should have been set for you). In that directory, there should be a symbolic link from "python3" to "python3.6" (in /usr/bin/ do a ls -al python*
). If what you want is python3, then the above should fix your problem.
You should be able to type "which python3". I don't know what "python" should point to (i.e., python2 or python3...I've lost track if it still points to python2). So, if what you're after is python 2.X, then you should check to see if it has been installed on your system.
Miniconda is a completely different issue. If you've installed Miniconda, you probably need to do a conda activate
. This would activate your base environment. Alternatively, if you want to find an environment, then conda activate <some environment>
. If you check your path, activating a Miniconda environment essentially prepends its path in front of PATH.
(You might want to double-check that conda is in your path; that is, if it was correctly installed. i.e., which conda
Also, the bottom of your ~/.bashrc
should have been modified.)
Given what you asked, I guess the second solution is what you wanted. But you should fix your PATH variable anyway.
Related videos on Youtube
YohanRoth
Updated on September 18, 2022Comments
-
YohanRoth over 1 year
If I type
which python
I get no output and I have no success using Miniconda as default Python. I did set paths to${HOME}/.profile
but no success.Here is my
${HOME}/.profile
The last line is mine. What am I doing wrong? My goal is to point to Miniconda3 by default.if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" fi export PATH="$PATH:/usr/bin/python3.6:/data/ubuntu/miniconda3/bin"
EDIT:
/usr/bin/python3.6
is a valid path, I installed python 3.6 and miniconda3.-
Eduardo Trápani over 4 yearsIf you run
python
, does it work?which
will only return a path if you actually able to run the command without having to specify its path. -
Kulfy over 4 yearsDo you expect
python
to invoke Python 3? Or you simply want Python 2?python
is a symlink to Python 2 and isn't installed by default in >18.04. Which Ubuntu version are you using? What is the output ofsudo apt install python
? -
YohanRoth over 4 years@GunnarHjalmarsson /usr/bin/python3
-
Gunnar Hjalmarsson over 4 yearsAnd what about:
python3 -V
-
Ray over 4 years@YohanRoth Regarding your edit, I don't think you understand what I mean. Is
/usr/bin/python3.6
a file, symbolic link, or a directory? The locations in the PATH variable should be directories only. You're providing locations for the shell to find files. You're not providing locations to the files themselves. In my case, I have Python 3.7 and it shows this: "-rwxr-xr-x 2 root root 4877888 Oct 7 20:56 /usr/bin/python3.7". This is a file and not a directory.
-