homebrew python@2 and python provides broken sqlite3
我正在使用最新版本的macOS和自制软件,brew医生没有发现任何错误。 我只是使用brew install python,brew install python @ 2来获取最新版本的python。
当我键入python -c"import sqlite3"时,我收到以下错误消息:
python2.7 -c"import sqlite3"
130 ? Traceback (most recent call last): File"", line 1, in
File
"/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/init.py",
line 24, in
from dbapi2 import * File"/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py",
line 28, in
from _sqlite3 import * ImportError: dlopen(/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so,
2): Symbol not found: _sqlite3_enable_load_extension Referenced
from:
/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
Expected in: /usr/lib/libsqlite3.dylib in
/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.sopython -c"import sqlite3"
1 ? Traceback (most recent call last): File"", line 1, in
File
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/init.py",
line 23, in
from sqlite3.dbapi2 import * File"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/dbapi2.py",
line 27, in
from _sqlite3 import * ImportError: dlopen(/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so,
2): Symbol not found: _sqlite3_enable_load_extension Referenced
from:
/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so
Expected in: /usr/lib/libsqlite3.dylib in
/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so
什么可能导致问题? 我试着下载python源代码并编译它,并将_sqlite3.so或_sqlite3.cpython-37m-darwin.so文件移动到brew安装文件夹中,一切正常。 可以酿造只是忘记配方中的东西? 除了从源代码编译.so文件并手动解决问题外,我该怎么办?
我终于找到了虫子隐藏的地方。
我所有的macOS设备(包括2个Pro和1个Air)共享相同的.zshrc文件,出于某种原因,我添加了一个
这破坏了python sqlite共享库文件的构建,为sqlite最近添加了一个名为'_sqlite3_enable_load_extension'的功能。
当我删除DYLD_LIBRARY_PATH到过时的目录,并刷新重新安装python一切都很好。
顺便说一下,brew config和brew doctor没有提供有关DYLD_LIBRARY_PATH的信息。 下次我将遵循规则并提供这些信息。
问题解决了!