4
venv/bin/pip install MySQL-python
Collecting MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 1.2MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/1j/pb3h7_hn4490px72_f8mntd00000gn/T/pip-build-o66zhy67/MySQL-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/1j/pb3h7_hn4490px72_f8mntd00000gn/T/pip-build-o66zhy67/MySQL-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/1j/pb3h7_hn4490px72_f8mntd00000gn/T/pip-build-o66zhy67/MySQL-python/

I am trying to install MySQL-python by pip but it threw above error. Can anyone help?

I have checked this page How to install Python MySQLdb module using pip? but it doesn't really help.

It's python3.5 in my virtualenv folder.

Community
  • 1
  • 1
Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
  • By your comment "It's python3.5 in my virtualenv folder" am I to assume you are doing this on some virtual box? What OS are you using? Doing a Google search for "python setup.py egg_info failed with error code 1" revealed [this SO question](http://stackoverflow.com/questions/35991403/python-pip-install-gives-command-python-setup-py-egg-info-failed-with-e) – Paul Stoner Nov 09 '16 at 17:08
  • 1
    I am not doing this on virtual box. `virtualenv` is a tool to create isolated Python environments – Haifeng Zhang Nov 09 '16 at 17:11

2 Answers2

3

I've been working on your setup and duplicated the result. Further research indicates that MySQL-python is only for Python 2.x. One recommendation I found is to use mysqlclient, but when I installed it I received the same error.

However, I am on a Windows 10 dev box using Visual Studio 2015 and I see an error regarding a file "my_config.h" is missing. Not certain if this is just my box or what.

I did find that installing PyMySql did seem to work, from an installation view point. I simply did pip install pymysql inside my virtual env. I found this solution here

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Paul Stoner
  • 1,359
  • 21
  • 44
  • 2
    thank you Paul. i searched the same result as you posted. MySQL-python is not valid for python3.x. `pip install mysqlclient` works for me. – Haifeng Zhang Nov 09 '16 at 19:03
-2

brew install mysql

After installation is complete, mysql path will be shown at the last. Use it in command

sudo PATH=/usr/local/Cellar/mysql/bin/:$PATH pip install mysql-python

  • 1
    This is specific to macOS, and needs more clarification. Also, why would a venv install by default require `sudo` rights? – Geeky I Nov 19 '17 at 14:46