OpenHarmony南向开发环境搭建中的几个常见问题【建议收藏】 原创

鸿蒙坚果派
发布于 2023-3-10 15:17
浏览
0收藏

在我们搭建OpenHarmony南向开发环境的时候,常常遇到各种问题,那么今天就做了一个整理贴。

执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。

升级python

python3 -m pip install -U pip

提示"cannot import ‘sysconfig’ from ‘distutils’"

现象描述

执行“python3 -m pip install --user ohos-build”提示"cannot import ‘sysconfig’ from ‘distutils’"。

执行如下命令安装。

sudo apt-get install python3.8-distutils

提示"module ‘platform’ has no attribute ‘linux_distribution’"

现象描述

执行“python3 -m pip install --user ohos-build”提示"module ‘platform’ has no attribute ‘linux_distribution’"。

可能原因

python3 pip安装兼容性问题。

sudo apt remove python3-pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

提示"Could not find a version that satisfies the requirement ohos-build"

现象描述

执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build"

解决办法

  1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。

  2. 若网络正常,请尝试指定临时pypi源的方式安装:

    python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build
    

提示“configure: error: no acceptable C compiler found in $PATH”

现象描述

安装python3过程中出现以下错误:

configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details

解决办法

1、通过命令“apt-get install gcc”在线安装。

2、完成后,重新安装python3。

提示“-bash: make: command not found”

现象描述

安装python3过程中出现以下错误:

-bash: make: command not found

解决办法

1、通过命令“apt-get install make”在线安装。

2、完成后,重新安装python3。

提示“zlib not available”

现象描述

安装python3过程中出现以下错误:

zipimport.ZipImportError: can't decompress data; zlib not available

解决办法

通过命令“apt-get install zlib”在线安装,完成后,重新安装python3。

提示“No module named ‘_ctypes’”

现象描述

安装python3过程中出现以下错误:

ModuleNotFoundError:No module named ‘_ctypes’

环境中未安装“libffi”和“libffi-devel”。这个时候我们可以通过命令“apt-get install libffi* -y”,在线安装。完成后,重新安装python3。

安装kconfiglib过程中遇到lsb_release错误

现象描述

安装kconfiglib过程中遇到如下错误打印:

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

可能原因

lsb_release模块基于的python版本与现有python版本不一致

解决办法

执行"find / -name lsb_release",找到lsb_release位置并删除,如:“sudo rm -rf /usr/bin/lsb_release”

Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg”

现象描述

Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg"

可能原因

python3 apt安装兼容性问题。

解决办法

执行如下命令重新安装python3-apt。

sudo apt-get remove  python3-apt
sudo apt-get install python3-apt

hdc_std连接不到设备

现象描述

执行 "hdc_std list targets"命令后结果为:[Empty]

解决方法

  1. 设备没有被识别: 在设备管理器中查看是否有hdc设备,在通用串行总线设备中会有“HDC Device”信息。如果没有,hdc无法连接。此时需要断开并重联PC和OpenHarmony设备之间的USB连接,或者烧写最新的镜像。
  2. hdc_std工作异常: 可以执行"hdc kill"或者"hdc start -r"杀掉hdc服务或者重启hdc服务,然后再执行hdc list targets查看是否已经可以获取设备信息。
  3. hdc_std与设备不匹配: 如果设备烧写的是最新镜像,hdc_std也需要使用最新版本。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
1
收藏
回复
举报
回复
    相关推荐