mac下 python3.5安装mysqlclient

由于本人使用的mac+python3.5安装MySQLdb报错

网上搜索后发现mac版本python3以上安装 brew install mysqlclient

mysqlclient(https://github.com/PyMySQL/mysqlclient-python)github地址

Prerequisites

You may need to install the Python and MySQL development headers and libraries like so:

sudo apt-get install python-dev libmysqlclient-dev # Debian / Ubuntu

sudo yum install python-devel mysql-devel # Red Hat / CentOS

On Windows, there are binary wheel you can install without MySQLConnector/C or MSVC.

Note on Python 3 : if you are using python3 then you need to install python3-dev using the following command :

sudo apt-get install python3-dev # debian / Ubuntu

sudo yum install python3-devel # Red Hat / CentOS

brew install mysql-connector-c # macOS (Homebrew)


安装  brew install mysql-connector-c # macOS (Homebrew)

继续报错:

brew install mysql-connector-c produces an error on macOS Sierra: Error: Cannot install mysql-connector-c because conflicting formulae are installed. mysql: because both install MySQL client libraries Please brew unlink mysql before continuing. Unlinking removes a formula's symlinks from /usr/local. You can link the formula again after the install finishes. You can --force this install, but the build may fail or cause obscure side-effects in the resulting software.

brew unlink mysql

继续填坑

nstall mysql connector using homebrewbrew install mysql-connector-c then install mysql-python using pippip install mysql-python or try PyMySQL its a pure python client library, you can install usingpip install PyMySQL and upgrade setuptools.

pip install --upgrade setuptools.


继续走:

Install from source

  1. Download source by git clone [email protected]:PyMySQL/mysqlclient-python.git
  2. Customize site.cfg
  3. python setup.py install

ok 






你可能感兴趣的:(mac下 python3.5安装mysqlclient)