2

I am new to coding and ubuntu, and I am trying to insert some data to MySQL using Python, but I am having some error in installing the mysql module.

I am having this error:

**pip install mysql**
Defaulting to user installation because normal site-packages is not writeable
Collecting mysql
  Using cached mysql-0.0.2.tar.gz (1.9 kB)
Collecting mysqlclient
  Using cached mysqlclient-2.0.2.tar.gz (88 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/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-pip-egg-info-ocgktfp6
         cwd: /tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/
    Complete output (12 lines):
    /bin/sh: 1: mysql_config: not found
    /bin/sh: 1: mariadb_config: not found
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup_posix.py", line 65, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
3
  • pip install mysql-connector-python try this , if you are still facing the issue, check your python version, make sure it is python3.8 and above Commented Dec 22, 2020 at 13:09
  • Thank you very much! I was able to successfully connect it! Commented Dec 22, 2020 at 15:30
  • ok then i will move it to answer Commented Dec 22, 2020 at 15:37

2 Answers 2

2

pip install mysql-connector-python try this , if you are still facing the issue, check your python version, make sure it is python3.8 and above.

Sign up to request clarification or add additional context in comments.

Comments

0

Hello and welcome to Python! A popular library used for interacting with MySQL database servers is "PyMySQL" and this can be found at: https://pypi.org/project/PyMySQL/

Installation Command:

pip install pymysql

You can view example usage here: https://pypi.org/project/PyMySQL/#example

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.