python setup.py egg_info mysqlclient

牧云@^-^@ 提交于 2019-11-27 19:09:05

This worked for me:

  1. brew install mysql-connector-c

  2. edit mysql_config (locate it: which mysql_config)

correct this in mysql_config:

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "

It shoud be:

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
  1. brew info openssl
  2. and finally pip3 install mysqlclient

I resolved this installing libmysqlclient-dev first:

sudo apt-get install libmysqlclient-dev

Hope it works for you.

After extensive troubleshooting, I found that the brew install mysql-connector-c just does not work.

The problem stems from the system not being able to identify that mysql_config is installed (which is what mysql-connector-c essentially does). Homebrew's method (open for argument) of installing the mysql-connector-c in its /Cellar/ and creating a symlink to the /usr/local/bin/ directory seems to be causing problems as Python tries to follow the symlink.

To resolve the issue I performed the following:

  1. brew uninstall mysql-connector-c
  2. download/install MacOS X MySQL Connector/C from Oracle's MySQL site
    • note: just download the .dmg, no need to be complicated here...
  3. restart MacOS Terminal (or iTerm2) for good measure
  4. which mysql_config

    • you should see the correct path /usr/local/bin/mysql/bin/mysql_config
  5. activate virtualenv (if applicable)

  6. pip install mysqlclient

There may be other ways to still use Homebrew, but this was the most straightforward solution I found.

Note that the mysqlclient GitHub README.md also states that the C-developer headers for Python3 are needed. I assume that mysql-connector-c includes those; however, should you run into more issues, you might also install the Xcode Developer CI Tools for good measure.

xcode-select --install

They include the C compiler and other developer utilities from Apple. Read more here.

Came across this while developing a django-based website, and I needed to set up the website to communicate with a mysql database. I've not used homebrew to do any of my installations.

Since I'm doing the development on a MacOS with Anaconda installed, I discovered that there was an issue with Anaconda. Without knowing the details, I was able to install mysqlclient with conda install mysqlclient

Hope that helps someone else with this problem as well.

Other options didn't work for me, but this worked for me:

For Python3:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip3 install mysqlclient

For Python2:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip2 install mysqlclient

or

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!