Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot install mysqlclient
#1
I am using python3.8 in django framework, for that I have to install mysqlclient. But error is coming when I try

pip3 install mysqlclient

output like this as error.
Output:
Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz ERROR: Command errored out with exit status 1: command: /home/LPython/my_env/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fgg27tgk/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fgg27tgk/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-fgg27tgk/mysqlclient/pip-egg-info cwd: /tmp/pip-install-fgg27tgk/mysqlclient/ Complete output (11 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <module> from setuptools.dist import Distribution, Feature File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/dist.py", line 35, in <module> from setuptools import windows_support File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module> import ctypes File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Reply
#2
1. did you install the prerequisites, as advised: https://pypi.org/project/mysqlclient/
2. why not use the official MySQL connector for python: https://dev.mysql.com/doc/connector-python/en/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Yes! I have installed Prerequisites as mentioned in the site. But still the error is coming Sad . I would like to prefer mysqlclient because mysqlclient is faster (sometimes > 10x faster).
Reply
#4
https://bugs.python.org/issue31652
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Do I need to set libffi any specific locations?
Reply
#6
My problem is solved. When I installed python-3.8.0, I did not compile it, that was the problem. I am using Centos7, so I went to the root of the terminal, first install prerequisites for Python before installing it.
# sudo yum install gcc openssl-devel bzip2-devel libffi-devel

download latest version

#wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

Now extract the downloaded package.

Compile Python Source

#cd Python-3.8.0
#sudo ./configure --enable-optimizations

make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

#sudo make altinstall

remove downloaded source archive file from your system

#sudo rm Python-3.8.0.tgz

Check Python Version

#python3.8 -V 

Then I could be able to install mysqlclient by
# pip3 install mysqlclient
Reply
#7
have had the same issue as lower version of mysqlclient was installed due to pymysql.

OS: Linux Mint 19.1

Python: 3.6.8

Django: 2.2.2

Uninstall mysqlclient: pip3 uninstall mysqlclient
Uninstall pymysql: pip3 uninstall pymysql
Install mysqlclient: pip3 install mysqlclient
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error while executing pip install mysqlclient kaykay 7 53,236 Mar-15-2019, 03:50 PM
Last Post: neilgomez

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020