Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install mysqlclient

Tags:

python

mysql

pip

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.

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.
like image 562
Anu Alex Avatar asked Dec 18 '19 09:12

Anu Alex


People also ask

How to install mysqlclient on CentOS?

python - Unable to install mysqlclient on centos - Stack Overflow. 1 1. Remove any MariaDB-devel. $ sudo yum erase MariaDB-devel.x86_64. 2 2. Add MySQL repository in yum. 3 3. Now, install mysql-devel. 4 4. Now, finally: mysqlclient.

Why can't I install MySQL-devel with mysqlclient?

I found that the problem is that mysqlclient requires mysql-devel packages, which is different from mariadb-devel. Don't install mariadb-devel! So, to install only mysql-devel, you need to: 1. Remove any MariaDB-devel $ sudo yum erase MariaDB-devel.x86_64 2. Add MySQL repository in yum

What is the basic syntax to run MySQL client?

mysql client the basic syntax is: mysql -u USER-NAME-HERE -h MYSQL-DB-SERVER-IP-ADDRESS-HERE -p DB-NAME mysql -u nixcraft -h server1.cyberciti.biz -p salesdata Share Improve this answer Follow answered Sep 29 '17 at 19:10 Gowtham BalusamyGowtham Balusamy 56888 silver badges2020 bronze badges 2


1 Answers

I think libffi-dev libary file is missing in your system/server. use the below command in order to check library installed or not

apt-cache search libffi

to install libffi-dev

sudo apt-get install -y libffi-dev

After that try

pip3 install mysqlclient

Approach 2

sudo apt-get install python-dev default-libmysqlclient-dev
sudo apt-get install python3-dev
pip install mysqlclient
like image 177
dhamo Avatar answered Sep 30 '22 05:09

dhamo