Installing MySQL Python on Mac OS X

后端 未结 15 1915
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 03:02

Long story short, when I write the following:

sudo easy_install MySQL-python

I get the error

EnvironmentError: mysql

相关标签:
15条回答
  • 2020-11-27 03:45

    Install mysql via homebrew, then you can install mysql python via pip.

    pip install MySQL-python
    

    It works for me.

    0 讨论(0)
  • 2020-11-27 03:45

    I am using OSX -v 10.10.4. The solution above is a quick & easy.

    Happening OSX does not have the connection library by default.

    First you should install the connector:

    brew install mysql-connector-c
    

    Then install with pip mysql

    pip install mysql-python
    
    0 讨论(0)
  • 2020-11-27 03:46

    The issue you are having is that the gcc compiler is not installed on your Mac. It will be installed if you have installed XCode. You will have to download gcc complier and install it manually. Follow the below link and download it -

    https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg

    I once had this problem installing Ruby 1.9 and I had to compile ruby for myself because Mountain Lion wasn't supported at that time. After installing the package, verify the install by the command gcc.

    0 讨论(0)
  • 2020-11-27 03:48

    For Python 3+ the mysql-python library is broken. Instead, use the mysqlclient library. Install with: pip install mysqlclient

    It is a fork of mysql-python (also known as MySQLdb) that supports Python 3+

    This library talks to the MySQL client's C-interface, and is faster than the pure-python pymysql libray.

    Note: you will need the mysql-developer tools installed. An easy way to do this on a Mac is to run

    brew install mysql-connector-c
    

    to delegate this task to homebrew. If you are on linux, you can install these via the instructions at the mysqlclient github page.

    0 讨论(0)
  • 2020-11-27 03:48

    I am using Python 2.7.11 :: Anaconda 2.3.0 (x86_64) on Mac OS X 10.11.4 15E65.

    You may want to follow the steps below:

    • Install homebrew
    • Open a terminal and run: brew install mysql-connector-c
    • pip install mysql-python

    Then the Anaconda will have the mysql-python installed and you can start with MySQLdb then.

    Good luck. Thanks.

    0 讨论(0)
  • 2020-11-27 03:49

    What worked for me is:

    LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python
    
    0 讨论(0)
提交回复
热议问题