conda command will prompt error: Bad Interpreter: No such file or directory
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.
What is the cause of Bad Interpreter: No such file or directory?
You have a script /home/ubuntu/env/bin/pip
and the script has shebang #!/home/ubuntu/env/bin/python
but the file is either absent or is not executable.
Check if the file /home/ubuntu/env/bin/python
exist. Check if it can be executed by the current user (just run it from the command line). If not — you need to find out a working executable (for example, it could be /home/ubuntu/env/bin/python3
), edit the first line of /home/ubuntu/env/bin/pip
to fix the shebang.
Bad Interpreter Error Trying to Install Packages in Anaconda
/transform/anaconda/bin/conda
expects the Python executable to be in /usr/local/anaconda/bin/python
since that is what is in its shebang line, but you've installed it elsewhere, specifically /transform/anaconda/bin/python
. You will need to modify the shebang line to point to the correct location.
`conda` gives No such file or Directory although I added PATH in my .bash_profile
Close that terminal and restart,It worked for me
AWS throws the following error: bad interpreter: No such file or directory
Option 1
Type
brew uninstall awscli
Then
brew install awscli
update python to 3.9.
look in the following post.
If this approach does not work for you, then try :
Option 2
Go to https://www.python.org/ and use the GUI installer for your OS
pip3 install awscli
Incorrect Conda path after linux system migration
I have fixed my issue using cpr
(credits to @merv). Here I post the detailed instructions, so if some one has the same problem, he/she can almost just follow them to get things fixed.
1. Installation
According to anaconda.org, the recommended command to install cpr
is
$ conda install -c anaconda conda-prefix-replacement
You may find this to be actually very awkward; the reason we need cpr
is that our conda
is broken due to the prefix issue, if we can run conda
command to install cpr
, then why should we need cpr
?
Instead, we may install cpr
directly from github:
$ git clone https://github.com/conda/conda-prefix-replacement.git
$ cd conda-prefix-replacement
$ python setup.py install
2. Rehome
After installation, running the rehome
command to fix the prefix issue is quite straightforward. Say your anaconda is moving from path_A
to path_B
, simply do
$ cpr rehome path_B --old-prefix path_A
In my case, the command should be
$ cpr rehome /local/scratch/xxx/anaconda3 --old-prefix /scratch/xxx/anaconda3
After running the cpr
command, exit the terminal and re-login. Everything should be good now!
Related Topics
How to Find All Comments with Beautiful Soup
Move Files from One Directory to Another with Paramiko
Name This Python/Ruby Language Construct (Using Array Values to Satisfy Function Parameters)
Automatically Create Requirements.Txt
Compiling Numpy with Openblas Integration
Why am I Getting a Filenotfounderror
Plot Different Color for Different Categorical Levels Using Matplotlib
Python Referencing Old Ssl Version
Linux: Pipe into Python (Ncurses) Script, Stdin and Termios
Python Ctypes - Loading Dll Throws Oserror: [Winerror 193] %1 Is Not a Valid Win32 Application
Replace Values in List Using Python
What's the How to Install Pip, Virtualenv, and Distribute for Python
How to Access "Static" Class Variables Within Methods in Python