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?

guerrato
  • 394
  • 1
  • 3
  • 12

1 Answers1

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

Adiii
  • 54,482
  • 7
  • 145
  • 148
  • It works when I have python and Mysql installed on docker, I have MySQL on docker and python locally. – guerrato Oct 09 '18 at 00:49
  • @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. – Light.G Oct 09 '18 at 01:26
  • So you can extend the mysql image and do modification for your self accordingly – Adiii Oct 09 '18 at 03:49
  • Thank a lot all of you, but the problem wasn't with my docker. I solved that following the https://zehengl.github.io/2017/12/17/pip-install-mysqlclient-on-macos/ – guerrato Oct 13 '18 at 20:11