症状:在我的 Django 应用程序中,当我调用 from pysqlite2._sqlite import * 时,我得到回溯 Symbol not found: _sqlite3_enable_load_extension 当
背景:
我试过了
brew uninstall sqlite 和brew uninstall python 并重新安装将这些添加到我的 .bash_profile
export PATH="$(brew --prefix sqlite)/bin:$PATH"
LDFLAGS="-L/usr/local/opt/sqlite/lib"
CPPFLAGS="-I/usr/local/opt/sqlite/include"
export PKG_CONFIG_PATH=“/usr/local/opt/sqlite/lib/pkgconfig”
python -c "import sqlite3"不返回任何错误
回溯要点:https://gist.github.com/xwchen/e9704fa34f0463d2117fe9fbb37922a1
最佳答案
Copied answer from here (https://github.com/Homebrew/homebrew-core/pull/3134). If you're like me, you probably installed sqlite after you install python3. Anyway, if anyone stumbles upon this question and needs an answer...
如果通过 Homebrew 软件安装,首先删除 SQLite、python 和 python3
brew uninstall --force python
brew uninstall --force python3
brew uninstall --force sqlite
这将删除所有副本。
然后确保安装了 Xcode 8 或更高版本
重要
通过
重新安装命令行工具xcode-select --install
sudo xcode-select --reset
最后通过找到的 pkg 文件安装命令行工具 here .
在搜索中查找命令行工具。 (我已经下载了“适用于 Xcode 8.dmg 的命令行工具 (macOS 10.12)”)然后打开 DMG 并安装在那里找到的 pkg。
现在安装 SQLite,然后根据需要安装 python 和 python 3:
brew install sqlite
brew install python
brew install python3
运行 brew install python --verbose 并确保没有警告,如果没有则应该解决问题。
不要忘记做
pip install setuptools --upgrade && pip3 install setuptools --upgrade
关于python - 找不到符号 : _sqlite3_enable_load_extension - sqlite installed via homebrew,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41994449/