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``` 
2
  • The mysqlclient pip package is a drop-in replacement. pip install mysqlclient
    – AKX
    CommentedAug 29, 2021 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 1CommentedAug 29, 2021 at 17:46

3 Answers 3

2

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

    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 
    1
    • I get the following errors when installing with the above command: ERROR: No matching distribution found for mysql-pythonprint """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 requiredModuleNotFoundError: No module named 'ConfigParser'CommentedAug 29, 2021 at 17:44
    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 
    5
    • I am using python 2.7 so the above distribution doesn't workCommentedAug 29, 2021 at 17:45
    • i there a good cause for using that putdqated Version of python?
      – nbk
      CommentedAug 29, 2021 at 17:48
    • @wheedwhackerjones i added a version for python 2.7
      – nbk
      CommentedAug 29, 2021 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 1CommentedAug 29, 2021 at 18:00
    • check this solution stackoverflow.com/a/61355803/5193536 and try to update to a newer python version
      – nbk
      CommentedAug 29, 2021 at 18:47

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.