1

I'm trying to install flask-mysql on ubuntu 18.04 and I keep getting this error:

(base) ether@ether:~/Documents/loginsystem$ pip install flask-mysqldb
Collecting flask-mysqldb
  Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /home/ether/anaconda3/lib/python3.7/site-packages (from flask-mysqldb) (1.0.2)
Collecting mysqlclient (from flask-mysqldb)
  Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
    Complete output from command python setup.py egg_info:
    /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-txlk8w2u/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 61, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-txlk8w2u/mysqlclient/

I tried to run sudo pip install and pip3 install flask-mysqldb but each time I received the same error as posted above.

What can I do to fix this?

0

1 Answer 1

11

The error message is pretty clear:

OSError: mysql_config not found

You need mysql_config. Install either libmariadbclient-dev or libmysqlclient-dev with apt.

Then try using pip again, but not with sudo.

Mixing system-level Python packages and pip-installed packages is a recipe for disaster. It looks like you already have a virtualenv for your project, so use that. Bonus points if you specify your dependencies in a requirements.txt file or Pipfile.

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

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.