我使用的是 Arch linux,并且按照 Anaconda 网站上的说明安装了 Anaconda。当我尝试运行 conda info --envs
时,出现以下错误:
bash: /home/lukasz/anaconda3/bin/conda: /opt/anaconda1anaconda2anaconda3/bin/python: bad interpreter: No such file or directory
我尝试查找目录 /opt/anaconda1anaconda2anaconda3/bin/python:
但它根本不存在。
此外,当我从终端运行 python 时,它正常运行,顶部显示以下内容
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.
为了完整起见,我的 .bashrc
文件类似于:
#
# ~/.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
我试过关注 this并进行适当的更改,但没有,我也尝试过 this但确实没有发布解决方案。
我想尝试解决此问题,而无需删除 Anaconda 并重新安装。
最佳答案
我想,安装过程中一定出了什么问题。 错误的解释器意味着脚本正在寻找不存在的解释器 - 正如您正确指出的那样。
问题可能出在 conda 脚本的 shebang #!
语句中。
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.
如果你跑了
cat ~/anaconda3/bin/conda
您可能会得到以下信息:
#!/opt/anaconda1anaconda2anaconda3/bin/python
if __name__ == '__main__':
import sys
import conda.cli
sys.exit(conda.cli.main())
更改第一行以指向正确的解释器,即将其更改为:
#!/home/lukasz/anaconda3/bin/python
应该使 conda
命令起作用。
如果您确定您已正确安装所有内容,那么我建议您联系 support from the anaconda community.
关于python - conda命令会提示错误: "Bad Interpreter: No such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39884499/