[英]MySQL on an Alpine python image is failing - Error loading shared library libmariadb?
My Dockerfile:我的 Dockerfile:
FROM python:3.8-alpine
...
RUN apk add --no-cache --virtual .build-deps gcc libffi-dev openssl-dev musl-dev mariadb-dev \
&& pip install --no-cache-dir -r /code/requirements/production.txt \
&& apk del .build-deps gcc libffi-dev musl-dev openssl-dev mariadb-dev
...
Requirements:要求:
django==2.2.9
mysqlclient==1.4.6
gunicorn==20.0.4
django-bootstrap3==12.0.3
django-fsm==2.7.0
djangorestframework==3.11.0
When I run the application I get this from django:当我运行应用程序时,我从 django 得到这个:
ImportError: Error loading shared library libmariadb.so.3: No such file or directory (needed by /usr/local/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-x86_64-linux-gnu.so)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
How can I fix this as I have already installed the MySQL db adapter recommeneded ?由于我已经安装了推荐的MySQL 数据库适配器,我该如何解决这个问题?
I found the issue on docker-alpine github我在docker-alpine github上发现了这个问题
The solution was to add the mariadb-connector-c-dev
package, before installing dependencies.解决方案是在安装依赖项之前添加mariadb-connector-c-dev
包。
RUN apk add --no-cache mariadb-connector-c-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.