gpt4 book ai didi

python导入sqlite错误

转载 作者:IT王子 更新时间:2023-10-29 06:23:58 25 4
gpt4 key购买 nike

python2.7 和 sqlite3 是通过 homebrew 在 macos 10.8 上安装的
pysqlite是通过pip安装的

当我在 python interapter 中键入 import sqlite3 时,它显示以下错误:

>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so, 2): Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib
Referenced from: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
Reason: image not found

如何纠正这个错误?

最佳答案

解决方案是同时卸载 sqlitepython kegs:

brew rm sqlite python

然后重新安装 Python(它还会安装 SQLite3 作为其依赖项):

brew install python

关于python导入sqlite错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15595473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com