simonw / db-to-sqlite

CLI tool for exporting tables or queries from any SQL database to a SQLite file
Apache License 2.0
368 stars 28 forks source link

pip install blows up when it can't find mysql? #16

Closed bknowles closed 5 years ago

bknowles commented 5 years ago

When trying to install this command, the "pip install" process does not check to see if there is a mysql command that has been previously installed, and bombs out with a nasty error:

$ pip3 install db-to-sqlite[mysql]
Collecting db-to-sqlite[mysql]
  Downloading https://files.pythonhosted.org/packages/36/3a/d758ef2009d6f33499c2ffcf7044d3fa52b03a1c96a7e53320aa0db90951/db_to_sqlite-1.0.1-py3-none-any.whl
Collecting sqlalchemy (from db-to-sqlite[mysql])
  Downloading https://files.pythonhosted.org/packages/62/3c/9dda60fd99dbdcbc6312c799a3ec9a261f95bc12f2874a35818f04db2dd9/SQLAlchemy-1.3.5.tar.gz (5.9MB)
    100% |████████████████████████████████| 5.9MB 5.2MB/s 
Collecting sqlite-utils>=1.4 (from db-to-sqlite[mysql])
  Downloading https://files.pythonhosted.org/packages/4f/f9/783c91652ef8ed4b0378f570c34b1cc6da03a34e59565127396153c6882d/sqlite_utils-1.4-py3-none-any.whl
Collecting click (from db-to-sqlite[mysql])
  Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
    100% |████████████████████████████████| 81kB 10.7MB/s 
Collecting mysqlclient; extra == "mysql" (from db-to-sqlite[mysql])
  Downloading https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
    100% |████████████████████████████████| 92kB 15.9MB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/7_/4p6y50v5595f9bhdpmhk3wbmt608x8/T/pip-install-39mqg7so/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/private/var/folders/7_/4p6y50v5595f9bhdpmhk3wbmt608x8/T/pip-install-39mqg7so/mysqlclient/setup_posix.py", line 51, in get_config
        libs = mysql_config("libs")
      File "/private/var/folders/7_/4p6y50v5595f9bhdpmhk3wbmt608x8/T/pip-install-39mqg7so/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7_/4p6y50v5595f9bhdpmhk3wbmt608x8/T/pip-install-39mqg7so/mysqlclient/

[1]+  Stopped                 pip3 install db-to-sqlite[mysql]

It would be great if the pip install process could be made a bit more intelligent, so that it refuses to install anything if it can't find a mysql command to work with.

simonw commented 5 years ago

Unfortunately I don't think there's much I can do here. Installing the MySQL client library has always been a real pain - it seems like every time I do it I figure out something new.

Three years ago this worked on OS X: https://gist.github.com/simonw/e6e2b495e020413566e4a81ba9f11679

More recently I got this to work: https://gist.github.com/simonw/90ac0afd204cd0d6d9c3135c3888d116

If anyone is going to solve this I would hope that the mysqlclient package maintainers are in with a better chance than I am.