Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install mysqlclient on Ubuntu LTS 16.04 LTS on Python3.6 #757

Closed
waqas80 opened this issue Oct 21, 2017 · 10 comments

Comments

@waqas80
Copy link

commented Oct 21, 2017

I installed and created a virtual environment on my Linux Ubuntu LTS 16.04 server. MySQL database is successfully installed and the database server is working. While trying to migrate django I get error that mysqlclient is not installed. When I try to install mysqlclient using the below command,
pip install mysqlclient
I am getting the below error,

Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /home/ubuntu/django_project/bin/python3.6 -u -c "import setuptools, tokenize;file='/tmp/pip-build-m44_w0__/mysqlclient/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/tmprdsdub84pip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'mysql' extension
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,12,'final',0) -D__version
=1.3.12 -I/usr/include/mysql -I/home/ubuntu/django_project/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
_mysql.c:32:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /home/ubuntu/django_project/bin/python3.6 -u -c "import setuptools, tokenize;file='/tmp/pip-build-m44_w0__/mysqlclient/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-hellghhe-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/django_project/include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'mysql' extension
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,12,'final',0) -D__version
=1.3.12 -I/usr/include/mysql -I/home/ubuntu/django_project/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
_mysql.c:32:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/home/ubuntu/django_project/bin/python3.6 -u -c "import setuptools, tokenize;file='/tmp/pip-build-m44_w0__/mysqlclient/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-hellghhe-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/django_project/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-build-m44_w0__/mysqlclient/

Please help me to solve the issue. I need urgent solution of this.

@waqas80

This comment has been minimized.

Copy link
Author

commented Oct 23, 2017

This is how I fix it.
sudo apt-get install python3.6-dev libmysqlclient-dev
after that I activate the virtual environment and execute the following command
pip install mysqlclient

@waqas80 waqas80 closed this Oct 23, 2017

@gechevarria

This comment has been minimized.

Copy link

commented May 4, 2018

Thank yo so much waqas80 for your input.
Some months later it has helped me a lot.
:-)

@jckleiner

This comment has been minimized.

Copy link

commented May 12, 2018

Worked for me. Thank you!

@elitelux

This comment has been minimized.

Copy link

commented May 17, 2018

Excellent waqas80!

@sirajalam049

This comment has been minimized.

Copy link

commented May 20, 2018

What about Centos yum repository?

@iqmal852

This comment has been minimized.

Copy link

commented May 30, 2018

thank @waqas80 work like a charm

@i0

This comment has been minimized.

Copy link

commented Jun 27, 2018

For CentOS users try:
yum install python36-devel

@Avadhanisarma

This comment has been minimized.

Copy link

commented Jul 5, 2018

kudos waqas80

@Augustinetharakan12

This comment has been minimized.

Copy link

commented Sep 16, 2018

This is how I fix it.
sudo apt-get install python3.6-dev libmysqlclient-dev
after that I activate the virtual environment and execute the following command
pip install mysqlclient

You are a life saver bro 👍 @waqas80

@fushenguang

This comment has been minimized.

Copy link

commented Jul 10, 2019

Thank you so much for your help. @waqas80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.