0

Part of my project requires the MySQL-python package. I'm running Linux Mint 20, kernel 5.11 I've had just about everything working fine up to this point. Just setup my virtual environment and all the packages install via poetry except MySQL-python. It fails with:

fatal error: my_config.h: No such file or directory
       44 | #include "my_config.h"
          |          ^~~~~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/matt/git/proj/test/python/.venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-f_UUOG/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-f_UUOG/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-XzgEIa/install-record.txt --single-version-externally-managed --compile --install-headers /home/matt/git/proj/test/python/.venv/include/site/python2.7/mysql-python Check the logs for full command output.

I tried adding a my_config_h folder to both /usr/local/mysql and /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.26 (where it is automatically setup). Not sure how to get past this.

I have export PATH=${PATH}:/usr/local/mysql/bin my bash config. I tried linking/unlinking mysql with brew.
Did lots of googling and solutions that worked for others do not work for me.

Thanks in advance.

EDIT: after solving a bunch of minor errors, the issue is now is this /home/linuxbrew/.linuxbrew/bin/ld: cannot find -lzstd These are packages I believe inside both usr/bin and the above directory.

Here is more of the error output:

    /home/linuxbrew/.linuxbrew/bin/ld: cannot find -lzstd
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1```
  • The `mysqlclient` pip package is a drop-in replacement. `pip install mysqlclient` – AKX Aug 29 '21 at 17:37
  • This throws the following error: ```/home/linuxbrew/.linuxbrew/bin/ld: cannot find -lzstd collect2: error: ld returned 1 exit status error: command 'x86_64-linux-gnu-gcc' failed with exit status 1``` – wheedwhackerjones Aug 29 '21 at 17:46

3 Answers3

2

This was resolved with the following command: sudo apt-get install libzstd-dev

0

With python 2.7 you can use

mysqlclient 1.3.5

pip install mysqlclient==1.3.5

MySQL-3.23 through 5.5 and Python-2.7, 3.3-3.4 are currently supported. PyPy is supported use for example instead

But you shopuld urentyl update to python 3.8 ot 3.9

mysql-connector-python 8.0.26

pip install mysql-connector-python
nbk
  • 45,398
  • 8
  • 30
  • 47
  • I am using python 2.7 so the above distribution doesn't work – wheedwhackerjones Aug 29 '21 at 17:45
  • i there a good cause for using that putdqated Version of python? – nbk Aug 29 '21 at 17:48
  • @wheedwhackerjones i added a version for python 2.7 – nbk Aug 29 '21 at 17:52
  • When attempting to install mysqlclient==1.3.5 I get this error (basically same as original) ```fatal error: my_config.h: No such file or directory 29 | #include "my_config.h" | ^~~~~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1``` – wheedwhackerjones Aug 29 '21 at 18:00
  • check this solution https://stackoverflow.com/a/61355803/5193536 and try to update to a newer python version – nbk Aug 29 '21 at 18:47
0

If you have the pip package manager on your system, try the following:

pip3 install mysql-python

In case pip is not there, run these commands first

sudo apt update
sudo apt install python3-pip
zephyr
  • 1,775
  • 6
  • 20
  • 31
  • I get the following errors when installing with the above command: ```ERROR: No matching distribution found for mysql-python``` ```print """You shouldn't be running this directly; it is used by setup.py.""" ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("""You shouldn't be running this directly)?``` ```raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: SSL is required``` ```ModuleNotFoundError: No module named 'ConfigParser'``` – wheedwhackerjones Aug 29 '21 at 17:44