LearningPath
LearningPath

Reputation: 93

Can't install flask-sqlalchemy mysql-python

since 2 Days I'm struggling to install this

pip install flask-sqlalchemy mysql-python

on my Ubuntu 20.4 (python 3.8) system. I've tried almost anything without success.

  1. first attempt
  2. second attempt
  3. thirsd attempt And now I dont know how to solve it since all the solutions I found didnt work for me.

Below are the error I got again and again.

on my Ubuntu 20.4 (python 3.8) system. I've tried almost anything without success.

  1. first attempt
  2. second attempt
  3. thirsd attempt And now I dont know how to solve it since all the solutions I found didnt work for me.

Below are the error I got again and again.

ERROR: Command errored out with exit status 1:
   command: /home/.../my_venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-npyk_a_5/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-npyk_a_5/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-oivzt0kv
       cwd: /tmp/pip-install-npyk_a_5/mysql-python/
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
  creating build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.linux-x86_64-3.8
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/.../my_venv/include -I/usr/include/python3.8 -c _mysql.c -o build/temp.linux-x86_64-3.8/_mysql.o
  _mysql.c:44:10: 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: Failed building wheel for mysql-python
  Running setup.py clean for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
    Running setup.py install for mysql-python ... error
    ERROR: Command errored out with exit status 1:
     command: /home/.../my_venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-npyk_a_5/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-npyk_a_5/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-owanenoz/install-record.txt --single-version-externally-managed --compile --install-headers /home/.../my_venv/include/site/python3.8/mysql-python
         cwd: /tmp/pip-install-npyk_a_5/mysql-python/
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
    creating build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-3.8
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/.../my_venv/include -I/usr/include/python3.8 -c _mysql.c -o build/temp.linux-x86_64-3.8/_mysql.o
    _mysql.c:44:10: 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/.../my_venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-npyk_a_5/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-npyk_a_5/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-owanenoz/install-record.txt --single-version-externally-managed --compile --install-headers /home/.../my_venv/include/site/python3.8/mysql-python Check the logs for full command output.

Upvotes: 0

Views: 451

Answers (1)

ig-
ig-

Reputation: 105

From the error you posted I would guess you've got some sort of missing mysql dependency.

    _mysql.c:44:10: fatal error: my_config.h: No such file or directory
       44 | #include "my_config.h"
          |          ^~~~~~~~~~~~~

Looking at the github page for mysqlclient maybe you could try running:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

In my experience, missing a .h file generally means there's a development library missing from your computer that the python extension needs

Upvotes: 1

Related Questions