Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conda command will prompt error: "Bad Interpreter: No such file or directory"

I'm using arch linux and I've installed Anaconda as per the instruction on the Anaconda site. When I'm attempting to run conda info --envs I get the following error:

bash: /home/lukasz/anaconda3/bin/conda: /opt/anaconda1anaconda2anaconda3/bin/python: bad interpreter: No such file or directory

I've tried looking for the directory /opt/anaconda1anaconda2anaconda3/bin/python: but it simply doesn't exist.

Furthermore, when I run python from the terminal it runs as normal with the following displayed at the top

Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:53:06)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. 

for completeness my .bashrc file resembles:

# # ~/.bashrc #  # If not running interactively, don't do anything [[ $- != *i* ]] && return  alias ls='ls --color=auto' PS1='[\u@\h \W]\$ '  # added by Anaconda3 4.0.0 installer export PATH="/home/lukasz/anaconda3/bin:$PATH"  # python startup for up keys export PYTHONSTARTUP=$HOME/.pythonstartup 

I've tried following this and making the the appropriate changes but nothing, I've also attempted to do this but there really isn't a solution posted.

I would like to try to fix this without having to remove Anaconda and reinstalling it.

like image 291
Lukasz Avatar asked Oct 05 '16 22:10

Lukasz


People also ask

Why does my command prompt not recognize Conda?

Environment PATH for Conda is not set – This is the most common cause why this issue occurs. Keep in mind that the latest Anaconda builds will not automatically add Conda to your System variable paths since it can cause various issues with other software.

Can I use Conda in command prompt?

Conda works on your command line interface such as Anaconda Prompt on Windows and terminal on macOS and Linux. Navigator is a desktop graphical user interface that allows you to launch applications and easily manage conda packages, environments, and channels without using command-line commands.


2 Answers

Something must have gone wrong during the installation, I suppose. The bad interpreter means that a script is looking for an interpreter that doesn't exist - as you rightfully pointed out.

The problem is likely to be in the shebang #! statement of your conda script.

From Wikipedia: Under Unix-like operating systems, when a script with a shebang is run as a program, the program loader parses the rest of the script's initial line as an interpreter directive; the specified interpreter program is run instead, passing to it as an argument the path that was initially used when attempting to run the script.

If you run

cat ~/anaconda3/bin/conda 

You will probably get the following:

#!/opt/anaconda1anaconda2anaconda3/bin/python if __name__ == '__main__':     import sys     import conda.cli      sys.exit(conda.cli.main()) 

Changing the first line to point a correct interpreter, i.e., changing it to:

#!/home/lukasz/anaconda3/bin/python 

Should make the conda command work.

If you are sure that you installed everything properly, then I'd suggest maybe reaching out for support from the anaconda community.

like image 106
dangom Avatar answered Sep 20 '22 06:09

dangom


I encountered the same error while trying

conda 

The error you should interpret as follows:

bash: "path_to_file_with_error": "path_to_file_it_points_to":  bad interpreter: No such file or directory 

How to fix Type in terminal

nano "path_to_file_with_error" 

Change first line of the file to correct path of the python (in my case it was in miniconda/bin)

like image 25
makewithplus Avatar answered Sep 19 '22 06:09

makewithplus