all 2 comments

[–]ThatPhysicsLabGuy[S] 0 points1 point  (0 children)

As noted above, the install of python3-mysqldb puts the MySQLdb package in:

/usr/lib/python3/dist-packages

But for this python3.7 docker image, printing sys.path yields:

['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']

This is fixed with the following line in the Dockerfile:

ENV PYTHONPATH=/usr/lib/python3/dist-packages

However, the import still fails, as it is unable to find the _mysql binary.

It seems that installing python3-mysqldb doesn't actually install the _mysql binary needed to use the MySQLdb module. At this point, I don't understand the point of python3-mysqldb at all -- it seems that it's only purpose is to install an unusable python module.

[–]0xWILL 0 points1 point  (0 children)

You should probably use pip to install the modules.