国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ARM平臺搭建Python環(huán)境

這篇具有很好參考價(jià)值的文章主要介紹了ARM平臺搭建Python環(huán)境。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

寫在最前

  1. 本文平臺為Ubuntu18.04,在搭建Python環(huán)境前,主機(jī)需要具備的環(huán)境有:gcc和make工具,以及聯(lián)網(wǎng)環(huán)境(下載有關(guān)lib-dev依賴項(xiàng))
  2. 交叉編譯工具為aarch64-linux-gnu

常見問題

Q:Ubuntu 18.04默認(rèn)安裝了Python3.6.9,那么在搭建Python環(huán)境時(shí)候,默認(rèn)的Python是否會對我們造成影響呢?
A:筆者安裝了好幾次,其實(shí)在安裝過程中,自帶的Python是不會對安裝造成影響的,但是安裝好之后,把系統(tǒng)自帶的與Python3.6.9的軟連接刪除之后,會存在錯誤情況,例如:Linux No module named ‘CommandNotFound‘,所以最好多版本Python并存,但是不刪除系統(tǒng)的Python環(huán)境

Q:使用sudo apt-get remove python3刪除系統(tǒng)的python再安裝是不是會好一點(diǎn)呢?
A:這樣可能造成更嚴(yán)重的錯誤,參考有:Ubuntu卸載python(慎重)

Q:ARM上安裝Python必須在宿主機(jī)上有該版本的Python環(huán)境嗎?
A:應(yīng)該是需要的吧?有博客提到,如果主機(jī)沒有Python環(huán)境,可能會出現(xiàn)checking for python interpreter for cross build... configure: error: python3.8 interpreter not found的錯誤:交叉編譯Python-3.8.3

Q:為啥我安裝的好的Python缺少ctypes、pip等包?
A:可能是在配置Python安裝包時(shí)候,主機(jī)沒有聯(lián)網(wǎng)下下來哪些依賴項(xiàng)目,其實(shí)如果依賴項(xiàng)是完整的,在源碼makePython時(shí)候都不會出現(xiàn)報(bào)錯,如:fatal error: ffi.h: No such file or directory這一類的錯誤

Q:我怎么知道需要哪些依賴項(xiàng)呢?
A:其實(shí)這個可以參考:Python Developer’s Guide

Q:交叉編譯3.8版本的Python主機(jī)環(huán)境的python必須叫python3.8嗎?
A:個人感覺是的,因?yàn)樵诮徊婢幾g時(shí)候,存在一個check的過程,內(nèi)容包括:checking for python3.8... python3.8 和 checking for python interpreter for cross build... python3.8,所以軟連接的python3.8.10應(yīng)當(dāng)叫python3.8

Q:交叉編譯的版本zlib和openssl模塊必須安裝嗎?
A:交叉編譯版本,如果不安裝zlib是沒有辦法啟動pip工具的如下所示,openssl可以根據(jù)需求決定

root@bot:~/pyenv/python3/lib/python3.8/site-packages# python3.8 -m pip list
Traceback (most recent call last):   File
"/home/root/pyenv/python3/lib/python3.8/runpy.py", line 194, in
_run_module_as_main
    return _run_code(code, main_globals, None,   File "/home/root/pyenv/python3/lib/python3.8/runpy.py", line 87, in
_run_code
    exec(code, run_globals)   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/__main__.py",
line 29, in <module>
    from pip._internal.cli.main import main as _main   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/cli/main.py",
line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py",
line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser   File
"/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py",
line 8, in <module>
    from pip._internal.cli import cmdoptions   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py",
line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/cli/parser.py",
line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError   File
"/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/configuration.py",
line 21, in <module>
    from pip._internal.exceptions import (   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_internal/exceptions.py",
line 8, in <module>
    from pip._vendor.requests.models import Request, Response   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_vendor/requests/__init__.py",
line 43, in <module>
    from pip._vendor import urllib3   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_vendor/urllib3/__init__.py",
line 13, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url   File
"/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py",
line 40, in <module>
    from .response import HTTPResponse   File "/home/root/pyenv/python3/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py",
line 5, in <module>
    import zlib ModuleNotFoundError: No module named 'zlib' root@bot:~/pyenv/python3/lib/python3.8/site-packages#

1. 主機(jī)(Ubuntu)安裝Python3.8.10

參考資料
Ubuntu安裝Python3

1.1 安裝前的準(zhǔn)備

    1. 下載Python源碼:Python Source Releases,打開頁面用瀏覽器工具找到對應(yīng)版本,隨便下載一個tar壓縮包即可

ARM平臺搭建Python環(huán)境

    1. Ubuntu環(huán)境準(zhǔn)備好依賴項(xiàng):sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
    1. 本文安裝位置:本文在Ubuntu的用戶(pcv)文件夾下創(chuàng)建了一個installPackage文件夾/home/pcv/installPackage用來存放Python源碼,最后安裝時(shí)候,將Python安裝在usr/local/python3.8文件夾里,這二者含義相當(dāng)于windows安裝的.exe位置和安裝位置:

ARM平臺搭建Python環(huán)境

至此可以檢查是否準(zhǔn)備好了安裝的條件

  • Ubuntu環(huán)境
  • python3.8.10源碼
  • gcc工具gcc -v 查看得到:gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04))
  • make工具make --version 查看得到:GNU Make 4.1 Built for x86_64-pc-linux-gnu)
  • lib-dev都已經(jīng)安裝完成
  • 明白了自己Python安裝目錄和源文件目錄區(qū)別
  • 理解了自己安裝目錄的位置和本文目錄位置可能不一樣~

1.2 Ubuntu安裝Python3.8.10

    1. 解壓源文件:tar -xvf Python-3.8.10.tar.xz,沒有權(quán)限記得添加權(quán)限sudo chmod 777 Python-3.8.10.tar.xz
    1. 進(jìn)入到源文件目錄 cd Python-3.8.10,并配置安裝位置和安裝方式:./configure --prefix=/usr/local/python3.8 --enable-optimizations
pcv@pc:~/installPackage$ tar -xvf Python-3.8.10.tar.xz 
pcv@pc:~/installPackage$ cd Python-3.8.10/
pcv@pc:~/installPackage$ ls
aclocal.m4          Doc         Mac              PC             setup.py
CODE_OF_CONDUCT.md  Grammar     Makefile.pre.in  PCbuild        Tools
config.guess        Include     Misc             Programs
config.sub          install-sh  Modules          pyconfig.h.in
configure           Lib         Objects          Python
configure.ac        LICENSE     Parser           README.rst
pcv@pc:~/installPackage/Python-3.8.10$ ./configure --prefix=/usr/local/python3.8 --enable-optimizations
  1. ./configure命令表示當(dāng)前文件夾下的configure配置
  2. --prefix=/usr/local/python3.8命令表示安裝位置
  3. --enable-optimizations比較耗時(shí)但是比較完整的安裝Python方式,據(jù)說低版本的gcc會在make指令之后提示make[1]: Leaving directory xxx信息,但是不影響make install
    1. 在一段check后即可編譯源文件:make,怕權(quán)限不夠可以sudo make,這一步耗時(shí)很長,如果依賴項(xiàng)不夠完整會出現(xiàn)某個.h文件fault的提示,編譯成功之后會出現(xiàn)makefile文件
pcv@pc:~/installPackage/Python-3.8.10$ make
.....
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Programs/_testembed.o ./Programs/_testembed.c
gcc -pthread     -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.8.a -lcrypt -lpthread -ldl  -lutil -lm   -lm 
make[1]: Leaving directory '/home/pcv/installPackage/Python-3.8.10'
pcv@pc:~/installPackage/Python-3.8.10$ ls
aclocal.m4          config.log     configure.ac  install-sh      Mac              Misc     PC                 pybuilddir.txt  Python            README.rst
build               config.status  Doc           Lib             Makefile         Modules  PCbuild            pyconfig.h      python-config     setup.py
CODE_OF_CONDUCT.md  config.sub     Grammar       libpython3.8.a  Makefile.pre     Objects  profile-run-stamp  pyconfig.h.in   python-config.py  Tools
config.guess        configure      Include       LICENSE         Makefile.pre.in  Parser   Programs           python          python-gdb.py
    1. 安裝Python:make install權(quán)限不夠則之間sudo make install,完整的安裝會提示最后把pip和setuptool也安裝好了
pcv@pc:~/installPackage/Python-3.8.10$ sudo make install
......
Looking in links: /tmp/tmp26hrxmp2
Processing /tmp/tmp26hrxmp2/setuptools-56.0.0-py3-none-any.whl
Processing /tmp/tmp26hrxmp2/pip-21.1.1-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.8 are installed in '/usr/local/python3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.1.1 setuptools-56.0.0
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv

1.3 Ubuntu配置Python3.8.10

    1. 安裝完成之后,在安裝目錄/usr/local/python3.8目錄下有Python3.8.10的二進(jìn)制可執(zhí)行文件,此時(shí)通過軟連接連接之后,即可使用該版本的Python軟件
pcv@pc:~/installPackage/Python-3.8.10$ cd /usr/local/python3.8/
pcv@pc:/usr/local/python3.8$ ls
bin  include  lib  share
pcv@pc:/usr/local/python3.8$ 
    1. 軟連接:sudo ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python3.8sudo ln -s /usr/local/python3.8/bin/python3.8-config /usr/bin/python3.8-config
    1. 后續(xù)通過命令python3.8使用python3.8.10軟件,通過命令python3.8 -m pip xxx使用python3.8.10的pip工具
pcv@pc:~/installPackage/Python-3.8.10$ sudo ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python3.8
pcv@pc:~/installPackage/Python-3.8.10$ python3.8
Python 3.8.10 (default, Dec 14 2022, 18:25:35) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[4]+  Stopped                 python3.8
pcv@pc:~/installPackage/Python-3.8.10$ sudo ln -s /usr/local/python3.8/bin/python3.8-config /usr/bin/python3.8-config
pcv@pc:~/installPackage/Python-3.8.10$ python3.8 -m pip list
Package    Version
---------- -------
pip        21.1.1
setuptools 56.0.0
^Z
[5]+  Stopped                 python3.8 -m pip list
pcv@pc:~/installPackage/Python-3.8.10$ 

2. 宿主機(jī)(AMR)安裝Python3.8.10

參考資料
交叉編譯詳解
交叉編譯工具鏈–aarch64安裝流程
交叉編譯Python-3.6.0到aarch64/aarch32 —— 支持sqlite3
python及第三方庫交叉編譯

2.1 主機(jī)安裝交叉編譯工具

    1. 下載交叉編譯工具aarch-linux-gnu-,Linaro Releases,有意思的是這個后綴是gnu而不是gun,筆者這里選擇的是109M的gnu.tar.xz,高版本的交叉編譯從GNU-A Downloads選擇下載

ARM平臺搭建Python環(huán)境

    1. 解壓aarch64-linux-gnu-:主要是記住文件的位置,因?yàn)楹罄m(xù)需要直接把a(bǔ)arch64-linux-gnu-工具添加到環(huán)境變量當(dāng)中:本文的位置為/home/用戶/aarch_gcc,采用了mv命令替換名字,
pcv@pc:~$ tar -xf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/
pcv@pc:~$ ls
Desktop    Downloads                                          gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar  Music     Public  Templates
Documents  gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu  installPackage                                         Pictures  share   Videos
pcv@pc:~$ rm gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar 
pcv@pc:~$ mv gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/ aarch_gcc
pcv@pc:~$ ls
aarch_gcc  Desktop  Documents  Downloads  installPackage  Music  Pictures  Public  share  Templates  Videos
pcv@pc:~$ cd aarch_gcc/bin/
pcv@pc:~/aarch_gcc/bin$ pwd
/home/pcv/aarch_gcc/bin
    1. 將aarch64-linux-gnu- 工具添加到環(huán)境變量:sudo echo "PATH=/home/pcv/aarch_gcc/bin:$PATH" >> ~/.bashrc,并激活環(huán)境變量:source ~/.bashrc ,至此輸入命令aarch64-linux-gnu-gcc --version 查看是否安裝完全
pcv@pc:~/aarch_gcc/bin$ sudo echo "PATH=/home/pcv/aarch_gcc/bin:$PATH" >> ~/.bashrc
pcv@pc:~/aarch_gcc/bin$ source ~/.bashrc 
pcv@pc:~/aarch_gcc/bin$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Linaro GCC 7.5-2019.12) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    1. 如果想通過交叉工具編譯C文件,則命令為:aarch64-linux-gnu-gcc test.c -o test

2.2 交叉編譯zlib庫

    1. 下載Zlib庫:zlib 官網(wǎng),目前最新版本應(yīng)該為1.2.13及以上,選擇源文件下載:

ARM平臺搭建Python環(huán)境

2.3 交叉編譯Python3.8.10

交叉編譯前面可以檢查是否準(zhǔn)備好了安裝的條件

  • Ubuntu環(huán)境存在python3.8的變量(終端輸入python3.8會有版本提示信息)
  • python3.8.10源碼
  • zlib源碼
  • aarch64-linux-gnu-工具
  • make工具make --version 查看得到:GNU Make 4.1 Built for x86_64-pc-linux-gnu)
  • lib-dev都已經(jīng)安裝完成
  • 同樣明白了目錄的含義

以下命令,均是能夠正常運(yùn)行之后的命令

2.2.1 交叉編譯Python3.8.10

    1. 進(jìn)入Python3.8.10源文件目錄,新建一個交叉編譯的文件夾,如本文的aarch_build,如果不新建交叉編譯的文件夾,會導(dǎo)致在源文件中make失敗,見2.3.2
pcv@pc:~/installPackage$ cd Python-3.8.10/
pcv@pc:~/installPackage/Python-3.8.10$ ls
aclocal.m4          config.log     configure.ac  install-sh      Mac              Misc     PC                 pybuilddir.txt  Python            README.rst
build               config.status  Doc           Lib             Makefile         Modules  PCbuild            pyconfig.h      python-config     setup.py
CODE_OF_CONDUCT.md  config.sub     Grammar       libpython3.8.a  Makefile.pre     Objects  profile-run-stamp  pyconfig.h.in   python-config.py  Tools
config.guess        configure      Include       LICENSE         Makefile.pre.in  Parser   Programs           python          python-gdb.py
pcv@pc:~/installPackage/Python-3.8.10$ ls
aclocal.m4          config.log     configure.ac  install-sh      Mac              Misc     PC                 pybuilddir.txt  Python            README.rst
build               config.status  Doc           Lib             Makefile         Modules  PCbuild            pyconfig.h      python-config     setup.py
CODE_OF_CONDUCT.md  config.sub     Grammar       libpython3.8.a  Makefile.pre     Objects  profile-run-stamp  pyconfig.h.in   python-config.py  Tools
config.guess        configure      Include       LICENSE         Makefile.pre.in  Parser   Programs           python          python-gdb.py
pcv@pc:~/installPackage/Python-3.8.10$ mkdir aarch_build
pcv@pc:~/installPackage/Python-3.8.10$ cd aarch_build/
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ ls
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ 
    1. 添加配置信息:CC=aarch64-linux-gnu-gcc CXX=aarch-linux-gnu-g++ LD=aarch64-linux-gnu-ld READELF=aarch64-linux-gnu-readelf ../configure --prefix=/home/pc/Desktop/python3 --build=aarch64-linux-gnu --host=aarch64-linux --target=aarch64-linux-gnu --enable-shared --enable-ipv6 --with-system-ffi ac_cv_file__dev_ptmx=0 ac_cv_file__dev_ptc=0 --enable-optimizations
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ CC=aarch64-linux-gnu-gcc CXX=aarch-linux-gnu-g++ LD=aarch64-linux-gnu-ld READELF=aarch64-linux-gnu-readelf ../configure --prefix=/home/pc/Desktop/python3 --build=aarch64-linux-gnu --host=aarch64-linux --target=aarch64-linux-gnu --enable-shared --enable-ipv6 --with-system-ffi ac_cv_file__dev_ptmx=0 ac_cv_file__dev_ptc=0 --enable-optimizations
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.8... python3.8
checking for python interpreter for cross build... python3.8
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
... ...
checking for sys/mman.h... (cached) yes
checking for shm_open... yes
checking for shm_unlink... yes
checking for aarch64-linux-pkg-config... /usr/bin/pkg-config
checking whether compiling and linking against OpenSSL works... no
checking for --with-ssl-default-suites... python
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile
    1. 清理舊的編譯目錄然后在交叉編譯文件夾下進(jìn)行交叉編譯:因?yàn)橹拔覀冊谠次募逻M(jìn)行過針對Ubuntu18.04的Python3.8.10編譯,,而交叉編譯的配置信息中的../configure也是針對源文件的配置,此時(shí)需要跳轉(zhuǎn)到該源文件位置清理編譯環(huán)境,sudo make clean,否則會出現(xiàn)Error: The source directory (..) is not clean,然后在交叉編譯的目錄aarch_build下執(zhí)行make命令
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ cd ..
pcv@pc:~/installPackage/Python-3.8.10$ sudo make clean
find . -depth -name '__pycache__' -exec rm -rf {} ';'
find . -name '*.py[co]' -exec rm -f {} ';'
find . -name '*.[oa]' -exec rm -f {} ';'
find . -name '*.s[ol]' -exec rm -f {} ';'
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
find build -name '*.py' -exec rm -f {} ';' || true
find build -name '*.py[co]' -exec rm -f {} ';' || true
rm -f pybuilddir.txt
rm -f Lib/lib2to3/*Grammar*.pickle
rm -f Programs/_testembed Programs/_freeze_importlib
find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
rm -f Include/pydtrace_probes.h
rm -f profile-gen-stamp
pcv@pc:~/installPackage/Python-3.8.10$ cd aarch_build/
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ make
Rebuilding with profile guided optimizations:
rm -f profile-clean-stamp
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS_NODIST=""
make[1]: Entering directory '/home/pcv/installPackage/Python-3.8.10/aarch_build'
aarch64-linux-gnu-gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include   -fPIC -DPy_BUILD_CORE -o Programs/python.o ../Programs/python.c
aarch64-linux-gnu-gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include   -fPIC -DPy_BUILD_CORE -o Parser/acceler.o ../Parser/acceler.c
... ...
aarch64-linux-gnu-gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include   -fPIC -DPy_BUILD_CORE -o Programs/_testembed.o ../Programs/_testembed.c
aarch64-linux-gnu-gcc     -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o -L. -lpython3.8 -lcrypt -lpthread -ldl  -lpthread -lutil -lm   -lm 
sed -e "s,@EXENAME@,/home/pc/Desktop/python3/bin/python3.8," < ../Misc/python-config.in >python-config.py
LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
make[1]: Leaving directory '/home/pcv/installPackage/Python-3.8.10/aarch_build'
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ 

2.2.2 ARM開發(fā)板配置Python3.8.10

2.3 針對編譯和配置過程中可能存在的報(bào)錯問題及解決

2.3.1 configure: error: readelf for the host is required for cross builds問題

  • 錯誤內(nèi)容:
checking for aarch64-linux-ar... no
checking for aarch64-linux-aal... no
checking for ar... ar
configure: WARNING: using cross tools not prefixed with host triplet
checking for aarch64-linux-readelf... no
checking for readelf... readelf
configure: error: readelf for the host is required for cross builds
  • 解決辦法:參考:Python3交叉編譯至arm-linux,但是本文設(shè)置軟連接無效,于是直接在環(huán)境中指定READELF=aarch64-linux-gnu-readelf

2.3.2 Error: The source directory (…) is not clean

  • 錯誤內(nèi)容:
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ make
Rebuilding with profile guided optimizations:
rm -f profile-clean-stamp
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS_NODIST=""
make[1]: Entering directory '/home/pcv/installPackage/Python-3.8.10/aarch_build'
Error: The source directory (..) is not clean
Building Python out of the source tree (in /home/pcv/installPackage/Python-3.8.10/aarch_build) requires a clean source tree (/home/pcv/installPackage/Python-3.8.10/aarch_build/..)
Try to run: make -C ".." clean
Makefile:470: recipe for target 'check-clean-src' failed
make[1]: *** [check-clean-src] Error 1
make[1]: Leaving directory '/home/pcv/installPackage/Python-3.8.10/aarch_build'
Makefile:522: recipe for target 'profile-opt' failed
make: *** [profile-opt] Error 
  • 解決辦法:其原因是因?yàn)樵谠次募械膍ake沒有清理一下,在源文件目錄下,運(yùn)行sudo make clean即可
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ cd ..
pcv@pc:~/installPackage/Python-3.8.10$ sudo make clean
find . -depth -name '__pycache__' -exec rm -rf {} ';'
find . -name '*.py[co]' -exec rm -f {} ';'
find . -name '*.[oa]' -exec rm -f {} ';'
find . -name '*.s[ol]' -exec rm -f {} ';'
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
find build -name '*.py' -exec rm -f {} ';' || true
find build -name '*.py[co]' -exec rm -f {} ';' || true
rm -f pybuilddir.txt
rm -f Lib/lib2to3/*Grammar*.pickle
rm -f Programs/_testembed Programs/_freeze_importlib
find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
rm -f Include/pydtrace_probes.h
rm -f profile-gen-stamp
pcv@pc:~/installPackage/Python-3.8.10$

2.3.3 error: the control flow of function ‘push’ does not match its profile data (counter ‘a(chǎn)rcs’)

  • 錯誤內(nèi)容:
pcv@pc:~/installPackage/Python-3.8.10$ make
aarch64-linux-gnu-gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include   -fPIC -DPy_BUILD_CORE -o Parser/parser.o Parser/parser.c
Parser/parser.c: In function ‘push’:
Parser/parser.c:348:1: error: the control flow of function ‘push’ does not match its profile data (counter ‘a(chǎn)rcs’) [-Werror=coverage-mismatch]
 }
 ^
Parser/parser.c:348:1: error: the control flow of function ‘push’ does not match its profile data (counter ‘time_profiler’) [-Werror=coverage-mismatch]
cc1: some warnings being treated as errors
Makefile:1730: recipe for target 'Parser/parser.o' failed
make[1]: *** [Parser/parser.o] Error 1
make[1]: Leaving directory '/home/pcv/installPackage/Python-3.8.10'
Makefile:522: recipe for target 'profile-opt' failed
make: *** [profile-opt] Error 2
  • 解決辦法:這是因?yàn)樵谠次募羞M(jìn)行配置和make,解決辦法則在源文件外新建build目錄為交叉編譯使用

2.3.4 fatal error: ffi.h: No such file or directory

  • 錯誤內(nèi)容:
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ make
... .f
aarch64-linux-gnu-gcc -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I../Include/internal -I../Include -IObjects -IPython -I. -I/home/pcv/aarch_gcc/bin/../aarch64-linux-gnu/libc/usr/include -I/home/pcv/installPackage/Python-3.8.10/Include -I/home/pcv/installPackage/Python-3.8.10/aarch_build -c /home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/_ctypes.c -o build/temp.linux-aarch64-3.8/home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/_ctypes.o
/home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/_ctypes.c:107:10: fatal error: ffi.h: No such file or directory
 #include <ffi.h>
          ^~~~~~~
compilation terminated.

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _hashlib           
_lzma                 _sqlite3              _ssl               
_tkinter              _uuid                 readline           
zlib                                                           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd                
time                                                           


Failed to build these modules:
_ctypes                                                        


Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381

running build_scripts
copying and adjusting /home/pcv/installPackage/Python-3.8.10/Tools/scripts/pydoc3 -> build/scripts-3.8
  • 參考內(nèi)容:

Python安裝報(bào)錯:”ModuleNotFoundError:No module named _ctypes“ 的解決方案
Python-3.8.12/Modules/_ctypes/_ctypes.c:107:17: 致命錯誤:ffi.h:沒有那個文件或目錄
fatal error: ffi.h: No such file or directory問題的解決
Linux安裝python3.8時(shí),編譯過程中報(bào)錯Could not build the ssl module!

  • 問題原因:事實(shí)上我們在最開始配置環(huán)境時(shí)候就已經(jīng)安裝好了這些依賴項(xiàng),關(guān)鍵失敗在于:aarch64-linux-gnu-gcc 編譯時(shí)候出現(xiàn)問題,如下所示,創(chuàng)建一個包含ffi.h的c文件編譯測試,交叉編譯發(fā)生報(bào)錯,但是為什么存在依賴項(xiàng)還是會交叉編譯出錯,這個可能是和Python版本兼容性不好有關(guān)系吧
#include "stdio.h"
#include "ffi.h"

int main()
{
    printf("hello\n");
    return 0;
}
pcv@pc:~/installPackage/devTest$ gcc test.c -o gccTest
pcv@pc:~/installPackage/devTest$ ./gccTest 
hello
pcv@pc:~/installPackage/devTest$ aarch64-linux-gnu-gcc test.c -o aarchTest
test.c:2:10: fatal error: ffi.h: No such file or directory
 #include "ffi.h"
          ^~~~~~~
compilation terminated.
pcv@pc:~/installPackage/devTest$ ls
gccTest  test.c
    1. 交叉編譯安裝libffi-dev:下載 libffi源文件,最新版本已經(jīng)更新到了3.4及以上,這里下載的是3.4.4版本,其他版本下載地址:Index of /sites/sourceware.org/pub/libffi/

交叉編譯前面可以檢查是否準(zhǔn)備好了安裝的條件

  • 準(zhǔn)備好交叉編譯aarch64-linux-gnu-工具
  • libffi源碼和編譯位置(本文在/home/pcv/installPackage/devTest/libffiEnv/路徑下進(jìn)行安裝)
  • 知道交叉編譯工具的環(huán)境路徑(配置時(shí)加入PATH的路徑,本文在/home/pcv/aarch_gcc下)
  • make工具make --version 查看得到:GNU Make 4.1 Built for x86_64-pc-linux-gnu)
    1. 解壓libffi源碼:sudo tar -xf libffi-3.4.4.tar.gz,然后進(jìn)入源文件目錄 cd libffi-3.4.4/
pcv@pc:~/installPackage/devTest/libffiEnv$ sudo chmod 777 libffi-3.4.4.tar.gz 
pcv@pc:~/installPackage/devTest/libffiEnv$ tar -xf libffi-3.4.4.tar.gz 
pcv@pc:~/installPackage/devTest/libffiEnv$ ls
libffi-3.4.4  libffi-3.4.4.tar.gz
pcv@pc:~/installPackage/devTest/libffiEnv$ cd libffi-3.4.4/
pcv@pc:~/installPackage/devTest/libffiEnv/libffi-3.4.4$ ls
acinclude.m4   compile       configure.ac    fficonfig.h.in                         libffi.map.in     libtool-version     m4              man         README.md
aclocal.m4     config.guess  configure.host  generate-darwin-source-and-headers.py  libffi.pc.in      LICENSE             Makefile.am     missing     src
ChangeLog      config.sub    depcomp         include                                libffi.xcodeproj  LICENSE-BUILDTOOLS  Makefile.in     msvc_build  testsuite
ChangeLog.old  configure     doc             install-sh                             libtool-ldflags   ltmain.sh           make_sunver.pl  msvcc.sh
pcv@pc:~/installPackage/devTest/libffiEnv/libffi-3.4.4$ 
    1. 新建交叉編譯文件目錄,并填寫配置文件:新建交叉編譯目錄 mkdir aarch_bulid,進(jìn)入交叉編譯目錄cd aarch_bulid,然后設(shè)置配置信息CC=aarch64-linux-gnu-gcc ../configure --host=aarch64-linux --build=aarch64-linux-gnu --target=aarch64-linux-gnu --enable-shared --prefix=/home/pcv/installPackage/devTest/libffiEnv/libffi
pcv@pc:~/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build$ CC=aarch64-linux-gnu-gcc ../configure --host=aarch64-linux --build=aarch64-linux-gnu --target=aarch64-linux-gnu --enable-shared --prefix=/home/pcv/installPackage/devTest/libffiEnv/libffi
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
checking for gsed... sed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a race-free mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
... ...
checking for __attribute__((visibility("hidden")))... yes
checking for shared libgcc... yes
configure: versioning on shared library symbols is gnu
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating include/Makefile
config.status: creating include/ffi.h
config.status: creating Makefile
config.status: creating testsuite/Makefile
config.status: creating man/Makefile
config.status: creating doc/Makefile
config.status: creating libffi.pc
config.status: creating fficonfig.h
config.status: executing buildir commands
config.status: skipping top_srcdir/Makefile - not created
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing include commands
config.status: executing src commands
    1. 執(zhí)行編譯和安裝命令:輸入make 進(jìn)行編譯,編譯完成之后進(jìn)行安裝sudo make install
make  all-recursive
make[1]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
Making all in include
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
Making all in testsuite
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/testsuite'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/testsuite'
Making all in man
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/man'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/man'
Making all in doc
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/doc'
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
depbase=`echo src/prep_cif.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/bash ./libtool  --tag=CC   --mode=compile aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -I. -I../include -Iinclude -I../src   -Wall  -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math -fexceptions -MT src/prep_cif.lo -MD -MP -MF $depbase.Tpo -c -o src/prep_cif.lo ../src/prep_cif.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -Wall -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math -fexceptions -MT src/prep_cif.lo -MD -MP -MF src/.deps/prep_cif.Tpo -c ../src/prep_cif.c  -fPIC -DPIC -o src/.libs/prep_cif.o
libtool: compile:  aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -Wall -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math -fexceptions -MT src/prep_cif.lo -MD -MP -MF src/.deps/prep_cif.Tpo -c ../src/prep_cif.c -o src/prep_cif.o >/dev/null 2>&1
depbase=`echo src/types.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/bash ./libtool  --tag=CC   --mode=compile aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -I. -I../include -Iinclude -I../src   -Wall  -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math -fexceptions -MT src/types.lo -MD -MP -MF $depbase.Tpo -c -o src/types.lo ../src/types.c &&\
mv -f $depbase.Tpo $depbase.Plo
... ...
libtool: link: aarch64-linux-gnu-gcc -shared  -fPIC -DPIC  src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/.libs/tramp.o src/aarch64/.libs/ffi.o src/aarch64/.libs/sysv.o    -O3 -Wl,--version-script -Wl,libffi.map   -Wl,-soname -Wl,libffi.so.8 -o .libs/libffi.so.8.1.2
libtool: link: (cd ".libs" && rm -f "libffi.so.8" && ln -s "libffi.so.8.1.2" "libffi.so.8")
libtool: link: (cd ".libs" && rm -f "libffi.so" && ln -s "libffi.so.8.1.2" "libffi.so")
libtool: link: ar cr .libs/libffi.a  src/prep_cif.o src/types.o src/raw_api.o src/java_raw_api.o src/closures.o src/tramp.o src/aarch64/ffi.o src/aarch64/sysv.o
libtool: link: ranlib .libs/libffi.a
libtool: link: ( cd ".libs" && rm -f "libffi.la" && ln -s "../libffi.la" "libffi.la" )
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
make[1]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
pcv@pc:~/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build$ sudo make install
Making install in include
make[1]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
make[2]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/home/pcv/installPackage/devTest/libffiEnv/libffi/include'
 /usr/bin/install -c -m 644 ffi.h ffitarget.h '/home/pcv/installPackage/devTest/libffiEnv/libffi/include'
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
make[1]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/include'
Making install in testsuite
make[1]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/testsuite'
make[2]: Entering directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build/testsuite'
... ...
----------------------------------------------------------------------
Libraries have been installed in:
   /home/pcv/installPackage/devTest/libffiEnv/libffi/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/home/pcv/installPackage/devTest/libffiEnv/libffi/lib/pkgconfig'
 /usr/bin/install -c -m 644 libffi.pc '/home/pcv/installPackage/devTest/libffiEnv/libffi/lib/pkgconfig'
make[2]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
make[1]: Leaving directory '/home/pcv/installPackage/devTest/libffiEnv/libffi-3.4.4/aarch_build'
    1. 將交叉編譯好的libffi添加到交叉工具環(huán)境中:打開交叉工具的目錄下的aarch64-linux-gnu文件夾,目錄為/home/pcv/aarch_gcc/aarch64-linux-gnu,(之前環(huán)境變量填的位置bin與該aarch64-linux-gnu為同一級,不是這個文件夾的bin位置),可以看到,libdiff目錄下有類似的文件結(jié)構(gòu),直接復(fù)制來合并到一起:sudo cp -rfp /home/pcv/installPackage/devTest/libffiEnv/libffi/* /home/pcv/aarch_gcc/aarch64-linux-gnu/

ARM平臺搭建Python環(huán)境

    1. 驗(yàn)證成功:此時(shí)在編譯之前包含ffi.h頭文件的c,aarch64-linux-gnu-gcc test.c -o aarchTest,會發(fā)現(xiàn)不再提示錯誤,即可開始編譯Python源碼

2.3.5 undefined symbol: ffi_prep_cif

root@bot:~/pyenv/python3/bin# python3.8
Python 3.8.10 (default, Dec 14 2022, 21:15:17)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/root/pyenv/python3/lib/python3.8/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: /home/root/pyenv/python3/lib/python3.8/lib-dynload/_ctypes.cpython-38-aarch64-linux-gnu.so: undefined symbol: ffi_prep_cif

aarch64-linux-gnu-gcc -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I../Include/internal -I../Include -IObjects -IPython -I. -I/home/pcv/aarch_gcc/bin/../aarch64-linux-gnu/libc/usr/include -I/home/pcv/installPackage/Python-3.8.10/Include -I/home/pcv/installPackage/Python-3.8.10/aarch_build -c /home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/callbacks.c -o build/temp.linux-aarch64-3.8/home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/callbacks.o
/home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/callbacks.c: In function ‘_ctypes_alloc_callback’:
/home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/callbacks.c:433:9: warning: ‘ffi_prep_closure’ is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
         result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
         ^~~~~~
In file included from /home/pcv/installPackage/Python-3.8.10/Modules/_ctypes/callbacks.c:6:0:
/home/pcv/aarch_gcc/aarch64-linux-gnu/include/ffi.h:375:1: note: declared here
 ffi_prep_closure (ffi_closure*,
 ^~~~~~~~~~~~~~~~

2.3.6 subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.

aarch_build/build/lib.linux-aarch64-3.8:../Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__linux_aarch64-linux-gnu python3.8 -m ensurepip \
		$ensurepip --root=/ ; \
fi
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/base_command.py", line 180, in _main
    status = self.run(options, args)
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_command.py", line 204, in wrapper
    return func(self, options, args)
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/commands/install.py", line 269, in run
    session = self.get_default_session(options)
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_command.py", line 77, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_command.py", line 87, in _build_session
    session = PipSession(
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/network/session.py", line 275, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_internal/network/session.py", line 132, in user_agent
    linux_distribution = distro.linux_distribution()  # type: ignore
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 681, in linux_distribution
    self.version(),
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/tmp/tmpt_xijb0r/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/home/pcv/installPackage/Python-3.8.10/Lib/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/pcv/installPackage/Python-3.8.10/Lib/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/home/pcv/installPackage/Python-3.8.10/Lib/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
pcv@pc:~/installPackage/Python-3.8.10/aarch_build$ sudo rm -rf /usr/bin/lsb_release

有意思的內(nèi)容:
Pre-release Python Installation:There was a time when is no official python installer was available for win/arm64 devices. However, packages for python 3.9 and above were available in Nuget and also could be compiled from sources as well. Please see the instructions below, if you interested about this process,翻譯的意思是:曾經(jīng)有一段時(shí)間,沒有官方的python安裝程序可用于win/arm64設(shè)備。但是,Python 3.9 及更高版本的包在 Nuget (Nuget是一個.NET平臺下的開源的項(xiàng)目,是Visual Studio的擴(kuò)展。)中可用,也可以從源代碼編譯。如果您對此過程感興趣,請參閱以下說明。文章來源地址http://www.zghlxwxcb.cn/news/detail-444093.html

到了這里,關(guān)于ARM平臺搭建Python環(huán)境的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【ARM 裸機(jī)】開發(fā)環(huán)境搭建

    【ARM 裸機(jī)】開發(fā)環(huán)境搭建

    使用過程中,要頻繁進(jìn)行 Ubuntu 和 Windows 的文件互傳,需要使用 FTP 服務(wù); 1.1、開啟 Ubuntu 下的 FTP 服務(wù) 修改結(jié)果,保證這兩行命令前面沒有 # ,保存退出; 重啟 FTP 服務(wù); 1.2、Windows 下安裝 FTP 客戶端 FileZilla 安裝好 FileZilla 客戶端之后,點(diǎn)擊文件選項(xiàng)進(jìn)入站點(diǎn)管理器,編號4輸

    2024年04月10日
    瀏覽(26)
  • VSCode搭建ARM開發(fā)環(huán)境

    VSCode搭建ARM開發(fā)環(huán)境

    為了構(gòu)建Cortex M系列單片機(jī)免費(fèi)開源的開發(fā)環(huán)境,網(wǎng)絡(luò)上了解來看VSCODE+GCC+JLINK是一套比較高效的組合方式,下面記錄環(huán)境搭建的流程。 我這邊的PC環(huán)境為 WIN7專業(yè)版64bit。 Visual Studio Code STM32Cubemx ARM GCC 交叉編譯工具鏈:? arm-none-eabi-gcc Windows版本的GCC編譯器:MinGW-W64或MinGW或T

    2024年03月21日
    瀏覽(22)
  • ARM-系統(tǒng)移植(開發(fā)環(huán)境搭建)

    ARM-系統(tǒng)移植(開發(fā)環(huán)境搭建)

    首先保證ubuntu連接網(wǎng)絡(luò)成功 1. 安裝步驟 作用:完成ubuntu和開發(fā)板之間傳輸文件 1)安裝tftp服務(wù)器的安裝包 sudo apt-get install tftpd-hpa? tftp-hpa ? ? ? ?tftpd-hpa : 服務(wù)器端 ? ? ? ?tftp-hpa : 客戶端? ?2)在家目錄下,創(chuàng)建一個文件夾 tftpboot ,并且添加最高權(quán)限 cd ~ mkdir? tftpboot ch

    2024年02月07日
    瀏覽(40)
  • Linux——ARM交叉編譯環(huán)境搭建

    Linux——ARM交叉編譯環(huán)境搭建

    可依據(jù)自己當(dāng)前的環(huán)境進(jìn)行選擇下載,官網(wǎng)如下??? Downloads | GNU-A Downloads – Arm Developer 我這邊選擇如下,用于4412開發(fā)板的 gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz mkdir??/usr/local/arm tar -xvf?gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz 在 vim /root/.bashrc 或 vim /etc/profi

    2024年02月21日
    瀏覽(23)
  • ubuntu環(huán)境下gcc-arm交叉編譯環(huán)境的搭建(ARM32 8.2)

    ubuntu環(huán)境下gcc-arm交叉編譯環(huán)境的搭建(ARM32 8.2)

    1.在arm官網(wǎng)下載gcc-arm 8.2的版本(下載arm32架構(gòu)的x64上運(yùn)行的版本),網(wǎng)址如下 https://developer.arm.com/downloads/-/gnu-a 圖1 從ARM官方下載aarch32架構(gòu)的交叉編譯器 ? 2.拷貝下載的交叉編譯器到ubuntu系統(tǒng)的/opt/pkg/gcc_linaro目錄,如下圖所示: 圖2 拷貝arm交叉編譯器到gcc安裝目錄 ? 3.解壓gcc到

    2024年02月09日
    瀏覽(22)
  • Qt5開發(fā)環(huán)境-銀河麒麟V10ARM平臺

    Qt5開發(fā)環(huán)境-銀河麒麟V10ARM平臺

    前言 近期因參與開發(fā)的某個軟件需要適配銀河麒麟v10arm 平臺,于是自己搭建起一套Qt 開發(fā)環(huán)境,在此記錄下具體過程,以供有需要的朋友參考。一開始手上并沒有Arm架構(gòu)的PC,先在Windows下用Vs2017和QtCreator 開發(fā),軟件開發(fā)快結(jié)束的時(shí)候Arm PC到了。Qt 沒有提供可直接安裝的arm架

    2024年02月12日
    瀏覽(23)
  • QEMU搭建arm虛擬機(jī)開發(fā)環(huán)境

    使用git指令切換到對應(yīng)的分支上,我這里使用的是stable-4.0的分支 git checkout -b stable-4.0 remotes/origin/stable-4.0 在工程的根目錄下執(zhí)行 ./configure --target-list=aarch64-linux-user,aarch64-softmmu --enable-virtfs --enable-debug 然后執(zhí)行make,視情況是否要執(zhí)行make install

    2024年01月25日
    瀏覽(20)
  • qemu搭建arm環(huán)境以及文件共享

    qemu搭建arm環(huán)境以及文件共享

    幾乎完全參照該文章 使用QEMU搭建ARM64實(shí)驗(yàn)環(huán)境 - 簡書 ?ubuntu 14.04,linux3.16, busybox-1.31.0 arm-linux-gnueabi-gcc -v linux3.16以及busybox下載安裝可參考鏈接 Ubuntu14.04安裝qemu,運(yùn)行l(wèi)inux-3.16+gdb調(diào)試_qemu 安裝 ubuntu 14_這個我好像學(xué)過的博客-CSDN博客 注意事項(xiàng) 1、文章中的命令arm64換為arm即可

    2024年02月06日
    瀏覽(24)
  • qemu-基礎(chǔ)篇——arm 裸機(jī)調(diào)試環(huán)境搭建

    裸機(jī)篇系列文章主要用于熟悉 arm 匯編及處理器結(jié)構(gòu) 本系列使用 mcimx6ul-evk mcimx6ul-evk 0x80000000-0xFFFFFFFF 2048MB 空間為 DDR 地址,所以將程序鏈接到 0x80000000 。 通過-Ttext 選項(xiàng),可以指定鏈接地址 -s :監(jiān)聽在 gdb 1234 端口 -S :表示啟動后就掛起,等待 gdb 連接 -kernel 指定啟用的內(nèi)核

    2024年01月21日
    瀏覽(19)
  • ARM學(xué)習(xí)筆記_1 介紹,Keil環(huán)境搭建

    ARM學(xué)習(xí)筆記_1 介紹,Keil環(huán)境搭建

    學(xué)習(xí)自b站一口linux老師的課程。 學(xué)習(xí)ARM需要學(xué)計(jì)算機(jī)原理,匯編,C語言,基本電路,硬件控制器原理,以及編寫相應(yīng)驅(qū)動程序。 了解系統(tǒng)啟動、上電、函數(shù)調(diào)用等底層實(shí)現(xiàn)。 真正地提高函數(shù)運(yùn)行效率。 一些軟件的破解…… 設(shè)計(jì)微處理器架構(gòu)的公司,包含三類:cortex-A, -R

    2024年02月05日
    瀏覽(30)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包