4

I have MySQL 5.7 installed on Docker running perfectly and python 3.7 installed locally.

I tried to install the flask-mysqldb using the command

pip install flask-mysqldb

and I received an error

OSError: mysql_config not found

I never had to install a MySQL client connector in my machine and never had any problem to connect any system.

Is this related to my Docker config? How can I solve this issue?

4
  • Where did u execute the pip install command? Inside mysql container? Commented Oct 8, 2018 at 13:17
  • The python is running at my machine, and the MySQL in docker, then running pip on docker wont't work. Commented Oct 8, 2018 at 15:07
  • @hoefling I've checked all the links you proposed before asking. First of all, I'm using Mac. Second, I'm trying to make my local connector works with docker container. Commented Oct 9, 2018 at 0:55
  • @Light.G, Yes. I did. The error is the same Commented Oct 9, 2018 at 0:55

1 Answer 1

1

Because the offical image of mysql:5.7 does not contain libmysqlclient-dev

just install this package and try again.

docker exec -it my_db bash
apt-get update
apt-get install libmysqlclient-dev

If there issue with pip Like in testing I faced then run

pip install --upgrade setuptools

https://hub.docker.com/_/mysql/

https://github.com/docker-library/mysql/blob/9d1f62552b5dcf25d3102f14eb82b579ce9f4a26/5.7/Dockerfile

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

4 Comments

It works when I have python and Mysql installed on docker, I have MySQL on docker and python locally.
@Guerrato Docker image is bunch of files and directories, just like Linux itself. Of course, docker image includes other files to declare how docker daemon deals with files above. So in the image mysql:5.7, it does not include extra files(packages) but those mysql needs. In a word, it’s not best practice to install other packages in mysql:5.7. We’d better keep it as thin as we could.
So you can extend the mysql image and do modification for your self accordingly
Thank a lot all of you, but the problem wasn't with my docker. I solved that following the zehengl.github.io/2017/12/17/pip-install-mysqlclient-on-macos

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.