python移植到 arm上面(可用)

python移植到 arm上面 (可以用)

环境是:ubuntu 18.04 64位

sudo apt-get install libffi-dev

安装 zlib

先去http://www.zlib.net/下载最新版本的zlib源码文件
安装zlib: /home/forlinx/work/python/zlib/
zlib-1.2.12.tar.gz
./configure
make
sudo make install

遇到问题

如何 在 arm debian 系统上 使用 python3?
交叉编译python3到ARM ,如何使用 pip

https://blog.csdn.net/u013546508/article/details/124884330

Python3.6.1的交叉编译
https://www.codenong.com/cs106053281/

使用的命令行

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
cd /home/forlinx/work/python/Python-3.8.10
./configure --prefix=/home/forlinx/work/python/pc_build
make -j2
sudo make install 
sudo  rm /usr/bin/python
sudo ln -s /home/forlinx/work/python/pc_build/bin/python3.8 /usr/bin/python
make clean
. /opt/fsl-imx-xwayland/5.4-zeus/environment-setup-aarch64-poky-linux 
./configure --prefix=/home/forlinx/work/python/build --host=aarch64-poky-linux --build=x86_64-linux-gnu ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no --target=aarch64-poky-linux --disable-ipv6 --enable-shared   
make -j2
sudo make install

cd ..
sudo cp -r build usr

tar zcvf arm-python3_8_10.tar.gz usr  

传到板子上面之后,
tar xvf arm-python3_8_10.tar.gz -C /

然后就是测试了,测试会有点问题,看下面。

root@OK8MP:/usr/bin#
root@OK8MP:/usr/bin# ls -lah python3*
lrwxrwxrwx 1 root root    9 Jun 23 11:17 python3 -> python3.7
lrwxrwxrwx 1 root root   16 Jun 23 11:17 python3-config -> python3.7-config
-rwxr-xr-x 1 root root 5.9K Jun 23 11:17 python3.7
lrwxrwxrwx 1 root root   17 Jun 23 11:17 python3.7-config -> python3.7m-config
-rwxr-xr-x 1 root root 5.9K Jun 23 11:17 python3.7m
lrwxrwxrwx 1 root root   30 Jun 23 11:17 python3.7m-config -> /usr/bin/python3.7m-config-lib
-rwxr-xr-x 1 root root 1.9K Jun 23 11:17 python3.7m-config-lib
root@OK8MP:/usr/bin#

编译通过了

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_tkinter              _uuid
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

running build_scripts
copying and adjusting /home/forlinx/work/python/Python-3.8.10/Tools/scripts/pydoc3 -> build/scripts-3.8
copying and adjusting /home/forlinx/work/python/Python-3.8.10/Tools/scripts/idle3 -> build/scripts-3.8
copying and adjusting /home/forlinx/work/python/Python-3.8.10/Tools/scripts/2to3 -> build/scripts-3.8
changing mode of build/scripts-3.8/pydoc3 from 664 to 775
changing mode of build/scripts-3.8/idle3 from 664 to 775
changing mode of build/scripts-3.8/2to3 from 664 to 775
renaming build/scripts-3.8/pydoc3 to build/scripts-3.8/pydoc3.8
renaming build/scripts-3.8/idle3 to build/scripts-3.8/idle3.8
renaming build/scripts-3.8/2to3 to build/scripts-3.8/2to3-3.8

sudo make install 出错

Traceback (most recent call last):
  File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen zipimport>", line 568, in _get_data
  File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 203, in run_                                                                             module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 144, in _get                                                                             _module_details
    return _get_module_details(pkg_main_name, error)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 111, in _get                                                                             _module_details
    __import__(pkg_name)
  File "<frozen zipimport>", line 241, in load_module
  File "<frozen zipimport>", line 709, in _get_module_code
  File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Traceback (most recent call last):
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 194, in _run                                                                             _module_as_main
    return _run_code(code, main_globals, None,
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 87, in _run_                                                                             code
    exec(code, run_globals)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__main__.py", line                                                                              5, in <module>
    sys.exit(ensurepip._main())
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              206, in _main
    return _bootstrap(
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              125, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              34, in _run_pip
    return subprocess.run([sys.executable, "-c", code], check=True).returncode
  File "/home/forlinx/work/python/Python-3.8.10/Lib/subprocess.py", line 516, in                                                                              run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python', '-c', '\nimport runp                                                                             y\nimport sys\nsys.path = [\'/tmp/tmpqz1n4aa3/setuptools-56.0.0-py3-none-any.whl                                                                             \', \'/tmp/tmpqz1n4aa3/pip-21.1.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] =                                                                              [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpq                                                                             z1n4aa3\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run                                                                             _module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit                                                                              status 1.
Makefile:1198: recipe for target 'install' failed
make: *** [install] Error 1

遇到新的错误1

http://t.zoukankan.com/lxw123123-p-14922496.html

ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/base_comm                                                                             and.py", line 180, in _main
    status = self.run(options, args)
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_comma                                                                             nd.py", line 204, in wrapper
    return func(self, options, args)
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/commands/inst                                                                             all.py", line 269, in run
    session = self.get_default_session(options)
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_comma                                                                             nd.py", line 77, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/cli/req_comma                                                                             nd.py", line 87, in _build_session
    session = PipSession(
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/network/sessi                                                                             on.py", line 275, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_internal/network/sessi                                                                             on.py", line 132, in user_agent
    linux_distribution = distro.linux_distribution()  # type: ignore
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 681, in linux_distribution
    self.version(),
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 741, in version
    self.lsb_release_attr('release'),
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl/pip/_vendor/distro.py", lin                                                                             e 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/subprocess.py", line 415, in                                                                              check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/forlinx/work/python/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/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 194, in _run                                                                             _module_as_main
    return _run_code(code, main_globals, None,
  File "/home/forlinx/work/python/Python-3.8.10/Lib/runpy.py", line 87, in _run_                                                                             code
    exec(code, run_globals)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__main__.py", line                                                                              5, in <module>
    sys.exit(ensurepip._main())
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              206, in _main
    return _bootstrap(
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              125, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/home/forlinx/work/python/Python-3.8.10/Lib/ensurepip/__init__.py", line                                                                              34, in _run_pip
    return subprocess.run([sys.executable, "-c", code], check=True).returncode
  File "/home/forlinx/work/python/Python-3.8.10/Lib/subprocess.py", line 516, in                                                                              run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python', '-c', '\nimport runp                                                                             y\nimport sys\nsys.path = [\'/tmp/tmpmyd8tlj4/setuptools-56.0.0-py3-none-any.whl                                                                             \', \'/tmp/tmpmyd8tlj4/pip-21.1.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] =                                                                              [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpm                                                                             yd8tlj4\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run                                                                             _module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit                                                                              status 2.
Makefile:1198: recipe for target 'install' failed
make: *** [install] Error 1

解决方法

查找缺失文件’lsb_release.py’,使用如下命令:
find / -name lsb_release
执行上述命令后,得到如下路径,以下仅为示例,用户实际可能有差别:
/usr/bin/lsb_release
将步骤1找到的“/usr/bin/lsb_release”文件备份:
mv /usr/bin/lsb_release /usr/bin/lsb_release.bak
然后执行pip3.7.5 list查看是否解决。

安装到板子上之后

root@OK8MP:~# pip3 install pyserial
Traceback (most recent call last):
File “/usr/bin/pip3”, line 6, in
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named ‘pkg_resources’

python -m ensurepip python -m pip install --upgrade pip setuptools wheel

在这里插入图片描述
在这里插入图片描述

参考

 export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
 ./configure --prefix=/home/forlinx/work/python/pc_build
 
 make -j2
 
 sudo make install 
 sudo  rm /usr/bin/python
 
 sudo ln -s /home/forlinx/work/python/pc_build/bin/python3.8 /usr/bin/python

 make clean
 . /opt/fsl-imx-xwayland/5.4-zeus/environment-setup-aarch64-poky-linux
 ./configure --prefix=/home/forlinx/work/python/build --host=aarch64-poky-linux --build=x86_64-linux-gnu ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no
 
  ./configure --prefix=/home/forlinx/work/python/build --host=aarch64-poky-linux --build=x86_64-linux-gnu ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no --target=aarch64-poky-linux --disable-ipv6 --enable-shared --with-zlib
  
  ../Python-3.8.10/configure --prefix=`pwd` --host=arm-none-linux-gnueabi --build=x86_64-linux-gnu --enable-shared ac_cv_file__dev_ptmx="yes" ac_cv_file__dev_ptc="no"  --enable-ipv6 --with-system-ffi --enable-optimizations --with-zlib

  
  make -j2
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值