linux python创建软链接失败解决办法

安装python3完成后使用软链接命令:

 ln -s /usr/local/Python3/bin/python3.6 /usr/bin/python

创建python软链接之后执行python

#python
-bash: /usr/bin/python: 没有那个文件或目录

解决软链接之前先检查一下

键入python3,测试一下python3是否正常

#python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

正常的话,继续进行下一步

#cd /
#cd /usr/bin/
#ls -al python*
# ls -al python*
-rwxr-xr-x 1 root root 11328 6月  18 21:45 python
lrwxrwxrwx 1 root root     9 4月  20 2021 python2 -> python2.7
-rwxr-xr-x 1 root root  7144 11月 17 2020 python2.7
-rwxr-xr-x 1 root root  1835 11月 17 2020 python2.7-config
lrwxrwxrwx 1 root root    16 8月  15 2021 python2-config -> python2.7-config
lrwxrwxrwx 1 root root     9 4月  20 2021 python3 -> python3.6
-rwxr-xr-x 2 root root 11328 11月 17 2020 python3.6
lrwxrwxrwx 1 root root    17 4月  20 2021 python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 11328 11月 17 2020 python3.6m
-rwxr-xr-x 1 root root   173 11月 17 2020 python3.6m-config
-rwxr-xr-x 1 root root  3403 11月 17 2020 python3.6m-x86_64-config
lrwxrwxrwx 1 root root    16 4月  20 2021 python3-config -> python3.6-config
-rwxr-xr-x 1 root root  7144 6月  18 21:44 python.back
lrwxrwxrwx 1 root root    14 8月  15 2021 python-config -> python2-config

执行命令 ,备份原本的软链接

#cp python python.back 

备份完成后复制python3的软链接

#cp python3 python33

直接复制为python的话会提示

# cp python3 python
cp:是否覆盖"python"? y
cp: 无法创建普通文件"python": 文本文件忙

所以,这里我们先复制一个python3

使用mv命令替换python

# mv python33 python
mv:是否覆盖"python"? y

输入y确认覆盖

测试一下

# python
Python 3.6.8 (default, Nov 16 2020, 16:55:22) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

手动设置软链接成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值