ubuntu 18上 install python 3.8 并实现软链接

在ubuntu上已经有不少python版本,在编译不同版本的yocto的时候,会用到不同 version 的python, 需要进行切换。

yocto branch dunfell 编译需要用到的是python 3.8.18, 原有的python 3.5,需要进行更新。

  1. download python 3.8.10
    wget https://www.python.org/ftp/python/3.8.18/Python-3.8.18.tgz
    如果从windows下载并拷贝过去,解压的时候有可能会报错
    tar -xzvf Python-3.8.18.tgz

  2. ./configure
    Python-3.8.18$ ./configure 后面不要跟prefix=/usr/bin 在后续make install的时候会存放在/usr/bin 以及 /usr/local/bin下

  3. make
    Python-3.8.18$ make

  4. sudo make install
    Python-3.8.18$ sudo make install

  5. 当前的python指向 python3.8.18

原有的python

/usr/bin$ ls -ll python*
lrwxrwxrwx 1 root root       9 421  2023 python -> python3.5
lrwxrwxrwx 1 root root       9 416  2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3628976 930  2020 python2.7
lrwxrwxrwx 1 root root      33 930  2020 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 416  2018 python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 1025  2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4452016 108  2019 python3.5
lrwxrwxrwx 1 root root      33 108  2019 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4452016 108  2019 python3.5m
lrwxrwxrwx 1 root root      34 108  2019 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 2 root root 4526456 311  2023 python3.6
lrwxrwxrwx 1 root root      33 311  2023 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 311  2023 python3.6m
lrwxrwxrwx 1 root root      34 311  2023 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root      16 1025  2018 python3-config -> python3.6-config
lrwxrwxrwx 1 root root      10 1025  2018 python3m -> python3.6m
lrwxrwxrwx 1 root root      17 1025  2018 python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root    2555 720  2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x 1 root root     314 720  2017 python-argcomplete-tcsh3
lrwxrwxrwx 1 root root      31 826  2021 python-config -> /usr/local/bin/python3.6-config在这里插入代码片

修改后的python
使用command: ln -s /usr/local/python 3.8 /usr/bin/python 来重新软链接


/usr/bin$ ls -ll python*
lrwxrwxrwx 1 root root      24 58 14:45 python -> /usr/local/bin/python3.8
lrwxrwxrwx 1 root root       9 416  2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3628976 930  2020 python2.7
lrwxrwxrwx 1 root root      33 930  2020 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 416  2018 python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 1025  2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4452016 108  2019 python3.5
lrwxrwxrwx 1 root root      33 108  2019 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4452016 108  2019 python3.5m
lrwxrwxrwx 1 root root      34 108  2019 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 2 root root 4526456 311  2023 python3.6
lrwxrwxrwx 1 root root      33 311  2023 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 311  2023 python3.6m
lrwxrwxrwx 1 root root      34 311  2023 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root      16 1025  2018 python3-config -> python3.6-config
lrwxrwxrwx 1 root root      10 1025  2018 python3m -> python3.6m
lrwxrwxrwx 1 root root      17 1025  2018 python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root    2555 720  2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x 1 root root     314 720  2017 python-argcomplete-tcsh3
lrwxrwxrwx 1 root root      31 58 14:54 python-config -> /usr/local/bin/python3.8-config

Python-3.8.18$ python --version
Python 3.8.18

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值