使用pyenv安装的python导入'_sqlite3'模块时找不到

Jingqiang Zhang :

pyenv在macOS上安装了python 3.7.0

sqlite3 已安装:

which sqlite3
/usr/bin/sqlite3

还尝试pysqlite3通过pip 安装

pip install pysqlite3

但是在导入时找不到模块sqlite3

In [1]: import sqlite3
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5239c6be4108> in <module>
----> 1 import sqlite3

~/.pyenv/versions/3.7.0/lib/python3.7/sqlite3/__init__.py in <module>
     21 # 3. This notice may not be removed or altered from any source distribution.
     22
---> 23 from sqlite3.dbapi2 import *

~/.pyenv/versions/3.7.0/lib/python3.7/sqlite3/dbapi2.py in <module>
     25 import collections.abc
     26
---> 27 from _sqlite3 import *
     28
     29 paramstyle = "qmark"

ModuleNotFoundError: No module named '_sqlite3'

是否需要通过brew在macOS上安装sqlite3的开发库?

Jingqiang Zhang :

这种方式有效:

CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.7.0

参考:

https://github.com/pyenv/pyenv/issues/108#issuecomment-359161050

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章