【问题标题】:Setting up Yocto on my Ubuntu (Ubuntu 18.04.3 LTS/bionic) with error "ImportError: No module named '_sqlite3'"在我的 Ubuntu(Ubuntu 18.04.3 LTS/bionic)上设置 Yocto 时出现错误“ImportError: No module named '_sqlite3'”
【发布时间】:2020-02-20 01:06:33
【问题描述】:

我的第一篇关于设置 Yocto 开发环境的帖子 在我的 Ubuntu 系统(Ubuntu 18.04.3 LTS/bionic)上,根据文档中包含的信息 此网页链接 (https://www.yoctoproject.org/docs/current/brief-yoctoprojectqs/brief-yoctoprojectqs.html)。

All is well until... ~/poky/build$ bitbake core-image-sato

which results in this error:

File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'

Below is my effort to proceed past this error, which didn't resolve the 
error above.  Please be generous and provide some guidance.  I searched for 
relevant posting locations; any advice on a better place is appreciated.    

Thank you.

------------------------------------------------

A web search on this error () results in:
How to Use SQLite in Ubuntu | Chron.com 
with

~/poky/build$ sudo apt-get install sqlite3 libsqlite3-dev

which tells me this:

Reading package lists... Done
Building dependency tree 
Reading state information... Done
libsqlite3-dev is already the newest version (3.22.0-1ubuntu0.1).
sqlite3 is already the newest version (3.22.0-1ubuntu0.1).
The following packages were automatically installed and are no longer 
required:
linux-headers-5.0.0-23 linux-headers-5.0.0-23-generic linux-image-5.0.0-23-generic linux-modules-5.0.0-23-generic
linux-modules-extra-5.0.0-23-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.

So, evidently sqlite3 exists on my system.  Here are the SO references that I checked:

[ImportError: No module named '_sqlite3' in python3.3][1]
[importerror no module named '_sqlite3' python3.4][2]
[ImportError: No module named _sqlite3 (even after doing eveything)][3]
[ImportError: No module named _sqlite3][4]


[1]: https://stackoverflow.com/questions/20126475/importerror-no-module-named-sqlite3-in-python3-3
[2]: https://stackoverflow.com/questions/24052137/importerror-no-module-named-sqlite3-python3-4
[3]: https://stackoverflow.com/questions/35889383/importerror-no-module-named-sqlite3-even-after-doing-eveything
[4]: https://stackoverflow.com/questions/2665337/importerror-no-module-named-sqlite3

【问题讨论】:

  • 据恩智浦半导体人称,Ubuntu_18.04需要Python3.6;然后我可以安装安装 sqlite3。我的系统安装了 Python3.5 和 Python3.6,在不同的目录中;可能是什么让 bitbake/Yocto 感到困惑。检查我的 Ubuntu_18.04 系统,我发现... Python3.6 安装在 /usr/bin/ 中... lrwxrwxrwx python3 -> python3.6 -rwxr-xr-x python3.6 其中 python3 指向 3.5 版本/usr/local/bin/ as... lrwxrwxrwx python3 -> python3.5 -rwxr-xr-x python3.5 /usr/local/bin/ 中到 3.5 的符号链接取代 /usr/bin 中到 3.6 的符号链接/。删除到 3.5 的链接?

标签: sqlite yocto ubuntu-18.04 bitbake


【解决方案1】:

我刚刚开始了一个构建,在一个全新的 Ubuntu 18.04 安装上逐字验证了 Brief-Quickstart 步骤。甚至根本没有安装 SQLite,但构建进展顺利。因此,您的开发主机中的 python 安装很有可能以某种方式被破坏。然而,这可能是有原因的:

  • 您可能明确选择了 python 3.5,因为您所做的其他一些事情需要它
  • 您可能隐式选择了 python 3.5,因为您从旧安装转发、安装了依赖它的东西或类似的东西。

无论如何,我猜现在修改链接可能会破坏您机器上其他地方的东西,恕我直言,应该避免这种情况。

那么你现在有什么选择?我的建议是开始在容器中构建,最简单的方法是安装 docker 并启动 docker run -it ubuntu:bionic /bin/bash - 至少要验证一切正常。

从长远来看,您可能希望为此添加一两个特殊容器:

1) 已经设置了所有需要的包 2) 使用标准用户而不是 root。

这是我个人做事的方式。另一种方法是使用CROPS 准备的东西,因为它是一种已知的良好解决方案,并且可以显着减少源自主机系统特性的问题。

【讨论】:

  • 我自己安装了python3.5,因为我尽量保留一个版本,直到最新版本被广泛安全地使用。我只为 Spyder 使用 3.5。这是一个全新的 Ubuntu 安装,除此之外。我会试试你的“码头工人”建议;不过,如果我删除 Python3.5 符号链接,我将无法再次重新启动。
猜你喜欢
  • 2023-03-15
  • 2015-05-08
  • 2017-07-01
  • 2017-02-01
  • 2018-10-02
  • 2020-07-24
  • 1970-01-01
  • 2018-12-07
  • 1970-01-01
相关资源
最近更新 更多