pip install mysqlclient 在 Ubuntu 上使用 docker 上的 python 2.7 失败

2023-12-01

当我运行下面的 docker 文件代码时

RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates \
        vim \
        git \
        python \
        python-pip \
        curl \
        wget \
        lsof \
        libmysqlclient-dev \
        python-dev \
        && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

#PYTHON requirements

ENV HTTPS_PROXY "https://gec-proxy-svr.homeoffice.wal-mart.com:8080/"

RUN python --version
RUN pip install pip --upgrade
RUN pip install  setuptools
RUN pip install setuptools --upgrade
RUN pip install git+https://github.com/PyMySQL/mysqlclient-python.git
RUN pip install -r requirements.txt

我收到这个错误

Running setup.py install for mysqlclient: finished with status 'error'
        Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-LIEfN7/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-OFwDUp/install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-2.7
        copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
        creating build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
        copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
        creating build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
        running build_ext
        building '_mysql' extension
        creating build/temp.linux-x86_64-2.7
        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
        unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

        ----------------------------------------
    Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-LIEfN7/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-OFwDUp/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-req-build-LIEfN7/

我尝试通过 apt-get update 安装 libmysqlclient-dev 和 python-dev 但它似乎没有解决问题。


Add build-essential到 apt-get 安装包列表。

看起来你的基础镜像非常基础,并且没有gcc安装了,所以你无法编译任何东西。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

pip install mysqlclient 在 Ubuntu 上使用 docker 上的 python 2.7 失败 的相关文章

随机推荐