Saq*_*Ali 5 pip mysql-python docker
这是我的 Dockerfile:
\n\nFROM python:2.7\nRUN apt-get update && apt-get -y upgrade\n#RUN apt-get install -y python-pip python-dev libmysqlclient-dev\nRUN pip install --upgrade pip\nRUN pip install MySQL-python==1.2.5\n
Run Code Online (Sandbox Code Playgroud)\n\n当我构建它时,我收到以下错误:
\n\nStep 4/4 : RUN pip install MySQL-python==1.2.5\n ---> Running in 60be606a8d3e\nDEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won\'t be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support\nCollecting MySQL-python==1.2.5\n Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)\nBuilding wheels for collected packages: MySQL-python\n Building wheel for MySQL-python (setup.py): started\n Building wheel for MySQL-python (setup.py): finished with status \'error\'\n ERROR: Command errored out with exit status 1:\n command: /usr/local/bin/python -u -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/setup.py\'"\'"\'; __file__=\'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/setup.py\'"\'"\';f=getattr(tokenize, \'"\'"\'open\'"\'"\', open)(__file__);code=f.read().replace(\'"\'"\'\\r\\n\'"\'"\', \'"\'"\'\\n\'"\'"\');f.close();exec(compile(code, __file__, \'"\'"\'exec\'"\'"\'))\' bdist_wheel -d /tmp/pip-wheel-oUG6qk --python-tag cp27\n cwd: /tmp/pip-install-IfSGpv/MySQL-python/\n Complete output (38 lines):\n running bdist_wheel\n running build\n running build_py\n creating build\n creating build/lib.linux-x86_64-2.7\n copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7\n creating build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb\n creating build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n running build_ext\n building \'_mysql\' extension\n creating build/temp.linux-x86_64-2.7\n gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,\'final\',1) -D__version__=1.2.5 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o\n In file included from _mysql.c:44:\n /usr/include/mariadb/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]\n #warning This file should not be included by clients, include only <mysql.h>\n ^~~~~~~\n In file included from _mysql.c:46:\n /usr/include/mariadb/mysql.h:440:3: warning: function declaration isn\xe2\x80\x99t a prototype [-Wstrict-prototypes]\n MYSQL_CLIENT_PLUGIN_HEADER\n ^~~~~~~~~~~~~~~~~~~~~~~~~~\n _mysql.c: In function \xe2\x80\x98_mysql_ConnectionObject_ping\xe2\x80\x99:\n _mysql.c:2005:41: error: \xe2\x80\x98MYSQL\xe2\x80\x99 {aka \xe2\x80\x98struct st_mysql\xe2\x80\x99} has no member named \xe2\x80\x98reconnect\xe2\x80\x99\n if ( reconnect != -1 ) self->connection.reconnect = reconnect;\n ^\n error: command \'gcc\' failed with exit status 1\n ----------------------------------------\n ERROR: Failed building wheel for MySQL-python\n Running setup.py clean for MySQL-python\nFailed to build MySQL-python\nInstalling collected packages: MySQL-python\n Running setup.py install for MySQL-python: started\n Running setup.py install for MySQL-python: finished with status \'error\'\n ERROR: Command errored out with exit status 1:\n command: /usr/local/bin/python -u -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/setup.py\'"\'"\'; __file__=\'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/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-Kpgfk8/install-record.txt --single-version-externally-managed --compile\n cwd: /tmp/pip-install-IfSGpv/MySQL-python/\n Complete output (38 lines):\n running install\n running build\n running build_py\n creating build\n creating build/lib.linux-x86_64-2.7\n copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7\n creating build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb\n copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb\n creating build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants\n running build_ext\n building \'_mysql\' extension\n creating build/temp.linux-x86_64-2.7\n gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,\'final\',1) -D__version__=1.2.5 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o\n In file included from _mysql.c:44:\n /usr/include/mariadb/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]\n #warning This file should not be included by clients, include only <mysql.h>\n ^~~~~~~\n In file included from _mysql.c:46:\n /usr/include/mariadb/mysql.h:440:3: warning: function declaration isn\xe2\x80\x99t a prototype [-Wstrict-prototypes]\n MYSQL_CLIENT_PLUGIN_HEADER\n ^~~~~~~~~~~~~~~~~~~~~~~~~~\n _mysql.c: In function \xe2\x80\x98_mysql_ConnectionObject_ping\xe2\x80\x99:\n _mysql.c:2005:41: error: \xe2\x80\x98MYSQL\xe2\x80\x99 {aka \xe2\x80\x98struct st_mysql\xe2\x80\x99} has no member named \xe2\x80\x98reconnect\xe2\x80\x99\n if ( reconnect != -1 ) self->connection.reconnect = reconnect;\n ^\n error: command \'gcc\' failed with exit status 1\n ----------------------------------------\nERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/setup.py\'"\'"\'; __file__=\'"\'"\'/tmp/pip-install-IfSGpv/MySQL-python/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-Kpgfk8/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.\n
Run Code Online (Sandbox Code Playgroud)\n\n如果我取消注释该行#RUN apt-get install python-pip python-dev libmysqlclient-dev
,则会收到以下错误:
Step 3/5 : RUN apt-get install python-pip python-dev libmysqlclient-dev\n ---> Running in 5593492607c7\nReading package lists...\nBuilding dependency tree...\nReading state information...\nPackage libmysqlclient-dev is not available, but is referred to by another package.\nThis may mean that the package is missing, has been obsoleted, or\nis only available from another source\nHowever the following packages replace it:\n libmariadb-dev-compat libmariadb-dev\n\nE: Package \'libmysqlclient-dev\' has no installation candidate\n
Run Code Online (Sandbox Code Playgroud)\n\n然后替换libmysqlclient-dev
为libmariadb-dev-compat libmariadb-dev
只会让我回到原来的错误。
如何将 MySQL-python 版本 1.2.5 安装到我的 docker 映像中?
\n根据 DockerHub
https://hub.docker.com/r/mikemanger/python27-mysql/
,这是您创建自己的映像文件的方式
FROM python:2.7.13
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get install -y mysql-server --no-install-recommends \
&& apt-get clean \
&& pip install PyMySQL \
&& pip install MySQL-python \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Run Code Online (Sandbox Code Playgroud)
可能有帮助!
归档时间: |
|
查看次数: |
3427 次 |
最近记录: |