在ubuntu上已经有不少python版本,在编译不同版本的yocto的时候,会用到不同 version 的python, 需要进行切换。
yocto branch dunfell 编译需要用到的是python 3.8.18, 原有的python 3.5,需要进行更新。
-
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 -
./configure
Python-3.8.18$ ./configure 后面不要跟prefix=/usr/bin 在后续make install的时候会存放在/usr/bin 以及 /usr/local/bin下 -
make
Python-3.8.18$ make -
sudo make install
Python-3.8.18$ sudo make install -
当前的python指向 python3.8.18
原有的python
/usr/bin$ ls -ll python*
lrwxrwxrwx 1 root root 9 4月 21 2023 python -> python3.5
lrwxrwxrwx 1 root root 9 4月 16 2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3628976 9月 30 2020 python2.7
lrwxrwxrwx 1 root root 33 9月 30 2020 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 4月 16 2018 python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 10月 25 2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4452016 10月 8 2019 python3.5
lrwxrwxrwx 1 root root 33 10月 8 2019 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4452016 10月 8 2019 python3.5m
lrwxrwxrwx 1 root root 34 10月 8 2019 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 2 root root 4526456 3月 11 2023 python3.6
lrwxrwxrwx 1 root root 33 3月 11 2023 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 3月 11 2023 python3.6m
lrwxrwxrwx 1 root root 34 3月 11 2023 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root 16 10月 25 2018 python3-config -> python3.6-config
lrwxrwxrwx 1 root root 10 10月 25 2018 python3m -> python3.6m
lrwxrwxrwx 1 root root 17 10月 25 2018 python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root 2555 7月 20 2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x 1 root root 314 7月 20 2017 python-argcomplete-tcsh3
lrwxrwxrwx 1 root root 31 8月 26 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 5月 8 14:45 python -> /usr/local/bin/python3.8
lrwxrwxrwx 1 root root 9 4月 16 2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3628976 9月 30 2020 python2.7
lrwxrwxrwx 1 root root 33 9月 30 2020 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 4月 16 2018 python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 10月 25 2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4452016 10月 8 2019 python3.5
lrwxrwxrwx 1 root root 33 10月 8 2019 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4452016 10月 8 2019 python3.5m
lrwxrwxrwx 1 root root 34 10月 8 2019 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 2 root root 4526456 3月 11 2023 python3.6
lrwxrwxrwx 1 root root 33 3月 11 2023 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 3月 11 2023 python3.6m
lrwxrwxrwx 1 root root 34 3月 11 2023 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root 16 10月 25 2018 python3-config -> python3.6-config
lrwxrwxrwx 1 root root 10 10月 25 2018 python3m -> python3.6m
lrwxrwxrwx 1 root root 17 10月 25 2018 python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root 2555 7月 20 2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x 1 root root 314 7月 20 2017 python-argcomplete-tcsh3
lrwxrwxrwx 1 root root 31 5月 8 14:54 python-config -> /usr/local/bin/python3.8-config
Python-3.8.18$ python --version
Python 3.8.18