安装 mysql-python 时出错:找不到 -lssl 的库
Error installing mysql-python: library not found for -lssl
我在安装 mysql-python 时遇到问题。创建了一个新的 virtualenv 并在安装 mysql-python 时...这是错误消息:
(env)$ pip install mysql-python
Collecting mysql-python
...
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
使用自制软件,我安装了:
- libresl
- openssl
- openssl@1.1
- mysql
已经尝试 brew link
但 brew 拒绝这样做。
OS 是 MacOS Sierra。
有人可以帮忙吗?谢谢!
通过以下步骤解决了问题:
brew uninstall mysql
brew install mysql-connector-c
pip install mysql-python
brew unlink mysql-connector-c
brew install mysql
在这里找到答案
不确定这是否正确,但这就是我设法解决问题的方法。
或从 MySQL 开发站点下载并安装 .dmg:https://dev.mysql.com/downloads/file/?id=467834
我终于能够通过
修复它
xcode-select --install
我确定我已经这样做了……但显然我没有。绝对值得一试!
这样做对我有用
$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python
上面的食谱略有改动(注意:pip install
最后!)
如果你想安装mysql-python
,我建议你安装mysqlclient
。这两个模块的作者是同一个人。至此,作者们都转而继续维护mysqlclient。 mysqlclient
支持 Python 2 和 Python 3。您可以使用与 mysql-python
相同的代码。 Blew 是我给你的安装方案。
$ brew info openssl
$ brew unlink mysql-connector-c
$ brew install mysql
$ brew link --overwrite mysql-connector-c
$ pip install mysqlclient
如果pip install mysqlclient
之前有错误。请按照methane's answer修正。
并且 运行 pip install mysqlclient
再次。
您可以显式设置 ssl 库路径。
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
我尝试更新 Xcode 的 CLT、卸载 mysql
、检查 mysql_config 等,但都没有成功。
我发现 运行 brew info openssl
显示:
...
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
...
运行 这两个命令,后跟 pip install
,对我有用(在我安装 mysqlclient
的情况下)。
对于正在安装 MySQL v5.7 with Brew 的用户
卸载mysql-connector-c
$ brew uninstall mysql-connector-c
安装特定版本,很可能需要卸载其他已安装的版本
$ brew install mysql@5.7
您需要将其添加到 PATH
,因为这是 'keg-only' 公式,安装后会打印出来
$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
用适当的文件替换 ~/.zshrc
。
安装mysql-connector-c
$ brew install mysql-connector-c
检查是否安装正确
$ which mysql
# /usr/local/opt/mysql@5.7/bin/mysql
$ mysql_config
# Usage: /usr/local/opt/mysql@5.7/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/opt/mysql@5.7/include/mysql ]
--cxxflags [-I/usr/local/opt/mysql@5.7/include/mysql ]
--include [-I/usr/local/opt/mysql@5.7/include/mysql]
--libs [-L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/opt/mysql@5.7/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.7.24]
--libmysqld-libs [-L/usr/local/opt/mysql@5.7/lib -lmysqld -lssl -lcrypto]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/opt/mysql@5.7/include/mysql]
pkglibdir [/usr/local/opt/mysql@5.7/lib]
plugindir [/usr/local/opt/mysql@5.7/lib/plugin]
现在安装mysqlclient
$ pip install mysqlclient
我可以通过 运行 修复错误:
pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
对我来说 mac,运行 这个命令解决了这个问题
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
实际上我们需要设置 ssl 库路径来解决这个问题。
我在安装 mysql-python 时遇到问题。创建了一个新的 virtualenv 并在安装 mysql-python 时...这是错误消息:
(env)$ pip install mysql-python
Collecting mysql-python
...
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
使用自制软件,我安装了:
- libresl
- openssl
- openssl@1.1
- mysql
已经尝试 brew link
但 brew 拒绝这样做。
OS 是 MacOS Sierra。
有人可以帮忙吗?谢谢!
通过以下步骤解决了问题:
brew uninstall mysql
brew install mysql-connector-c
pip install mysql-python
brew unlink mysql-connector-c
brew install mysql
在这里找到答案
不确定这是否正确,但这就是我设法解决问题的方法。
或从 MySQL 开发站点下载并安装 .dmg:https://dev.mysql.com/downloads/file/?id=467834
我终于能够通过
修复它xcode-select --install
我确定我已经这样做了……但显然我没有。绝对值得一试!
这样做对我有用
$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python
上面的食谱略有改动(注意:pip install
最后!)
如果你想安装mysql-python
,我建议你安装mysqlclient
。这两个模块的作者是同一个人。至此,作者们都转而继续维护mysqlclient。 mysqlclient
支持 Python 2 和 Python 3。您可以使用与 mysql-python
相同的代码。 Blew 是我给你的安装方案。
$ brew info openssl
$ brew unlink mysql-connector-c
$ brew install mysql
$ brew link --overwrite mysql-connector-c
$ pip install mysqlclient
如果pip install mysqlclient
之前有错误。请按照methane's answer修正。
并且 运行 pip install mysqlclient
再次。
您可以显式设置 ssl 库路径。
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
我尝试更新 Xcode 的 CLT、卸载 mysql
、检查 mysql_config 等,但都没有成功。
我发现 运行 brew info openssl
显示:
...
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
...
运行 这两个命令,后跟 pip install
,对我有用(在我安装 mysqlclient
的情况下)。
对于正在安装 MySQL v5.7 with Brew 的用户
卸载mysql-connector-c
$ brew uninstall mysql-connector-c
安装特定版本,很可能需要卸载其他已安装的版本
$ brew install mysql@5.7
您需要将其添加到 PATH
,因为这是 'keg-only' 公式,安装后会打印出来
$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
用适当的文件替换 ~/.zshrc
。
安装mysql-connector-c
$ brew install mysql-connector-c
检查是否安装正确
$ which mysql
# /usr/local/opt/mysql@5.7/bin/mysql
$ mysql_config
# Usage: /usr/local/opt/mysql@5.7/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/opt/mysql@5.7/include/mysql ]
--cxxflags [-I/usr/local/opt/mysql@5.7/include/mysql ]
--include [-I/usr/local/opt/mysql@5.7/include/mysql]
--libs [-L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/opt/mysql@5.7/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.7.24]
--libmysqld-libs [-L/usr/local/opt/mysql@5.7/lib -lmysqld -lssl -lcrypto]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/opt/mysql@5.7/include/mysql]
pkglibdir [/usr/local/opt/mysql@5.7/lib]
plugindir [/usr/local/opt/mysql@5.7/lib/plugin]
现在安装mysqlclient
$ pip install mysqlclient
我可以通过 运行 修复错误:
pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
对我来说 mac,运行 这个命令解决了这个问题
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
实际上我们需要设置 ssl 库路径来解决这个问题。