Error installing mysql-python: library not found f

2019-01-23 16:41发布

I'm having trouble installing mysql-python. Created a new virtualenv and when installing mysql-python... here's the error message:

(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

Using homebrew, I have installed:

  • libressl
  • openssl
  • openssl@1.1
  • mysql

Already tried to brew link but brew refuses to do so.

The OS is MacOS Sierra.

Can anyone help? Thanks!

8条回答
干净又极端
2楼-- · 2019-01-23 17:23

For those of you who are installing MySQL v5.7 with Brew

Uninstall mysql-connector-c

$ brew uninstall mysql-connector-c

Install specific version, very likely you need to uninstall other installed versions

$ brew install mysql@5.7

You will need to add it to the PATH, since this is 'keg-only' formulae, this is printed after it is installed

$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

Replace ~/.zshrc with the appropriate file.

Install mysql-connector-c

$ brew install mysql-connector-c

Check it is installed properly

$ 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]

Now install mysqlclient

$ pip install mysqlclient
查看更多
我想做一个坏孩纸
3楼-- · 2019-01-23 17:25

Solved it with these steps:

brew uninstall mysql
brew install mysql-connector-c
pip install mysql-python
brew unlink mysql-connector-c
brew install mysql

Found the answer here https://stackoverflow.com/a/25920020/576192

Not sure if this is the right way, but this is how I managed to solve it.

查看更多
登录 后发表回答