【问题标题】:Use Python 3 in OpenWRT Build System [closed]在 OpenWRT 构建系统中使用 Python 3 [关闭]
【发布时间】:2021-03-14 18:53:41
【问题描述】:

尝试在我的 Ubuntu 20 上根据manualOmega linux on chip 设备创建 OpenWRT 构建系统。运行make menuconfig 时出现以下错误

...
Checking 'python'... failed.
...
Build dependency: Please install Python 2.x

我的系统有Python 3,而手册要求安装Python 2

如何解决这个问题?

【问题讨论】:

  • 使用 virtualenv 在你的系统中创建一个隔离的 Python2 环境。
  • 无法用 Python 3 解决问题?
  • Python 3 不向后兼容。
  • 既然您在此处的编程论坛中提问,答案是将代码移植到 Python 3。也许还可以提交功能请求来为您执行此操作。或者,安装 Python 2。为什么要同时使用 C 和 C++ 来标记它,即使这两种语言都没有一个问题?

标签: python c++ c cmake openwrt


【解决方案1】:

由于 Python3 不向后兼容,您需要提供 Python2 进行安装。按照以下说明在您的系统中创建一个隔离的 Python2 环境:

  1. 安装 Python2(如果需要,添加存储库):
sudo apt install python2
  1. 安装 pip(包管理器):
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py

sudo python2 get-pip.py
  1. 安装 virtualenv:
sudo apt install virtualenv
  1. 在您喜欢的目录中为 Python2 创建虚拟环境(将 myenv 更改为您喜欢的名称):
virtualenv --python=python2 myenv
  1. 激活:
source myenv/bin/activate
  1. 停用:
deactivate

您还可以在激活的环境中使用 pip 安装所需的 python 包(如果需要)。

【讨论】:

    猜你喜欢
    • 2014-07-07
    • 2010-11-19
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    相关资源
    最近更新 更多