python环境报错,坏的解释器: 没有那个文件或目录

[xxxx@gs-server-7214 ~]$ /opt/anaconda3/bin/jupyter notebook
-bash: /opt/anaconda3/bin/jupyter: /opt/anaconda3/bin/python: 坏的解释器: 没有那个文件或目录
[xxxx@gs-server-7214 ~]$ /opt/anaconda3/bin/python3
Python 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[1]+  已停止               /opt/anaconda3/bin/python3

  1. 创建软连接
    已经通过/opt/anaconda3/bin/python3 -m pip install jupyter安装了jupyter,全路径下也可以启动python,但是全路径下启动jupyter报错如上,原因是anaconda默认解释器路径为/opt/anaconda3/bin/python,实际没有该文件,创建软连接python指向实际存在的解释器python3.6, 如下 -> 表示软连接
[xxxx@gs-server-7214 bin]$ ll |grep python
-rwxrwxr-x 1 root root      237 1024 2019 ipython
-rwxrwxr-x 1 root root      237 1024 2019 ipython3
lrwxrwxrwx 1 root root        9 716 16:31 python -> python3.6
lrwxrwxrwx 1 root root        9 828 2020 python3 -> python3.6
-rwxrwxr-x 1 root root 11947112 58 2020 python3.6
lrwxrwxrwx 1 root root       17 828 2020 python3.6-config -> python3.6m-config
lrwxrwxrwx 1 root root        9 828 2020 python3.6m -> python3.6
-rwxrwxr-x 1 root root     3477 828 2020 python3.6m-config
lrwxrwxrwx 1 root root       17 828 2020 python3-config -> python3.6m-config

2.设置环境变量
修改自己用户目录下的.bash_profile文件,添加环境变量,export PATH=/opt/anaconda3/bin:$PATH,冒号是分隔符。source .bash_profile使环境变量生效,这样在自己用户目录下直接输入jupyter notebook就可以启动jupyter了。


版权声明:本文为qq_43392533原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。