Docker Python2.7容器中安装第三方库GCC提示:file not recognized: File format not recognized

Posted Jann

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker Python2.7容器中安装第三方库GCC提示:file not recognized: File format not recognized相关的知识,希望对你有一定的参考价值。

问题描述:

在Docker容器中安装Python第三方库时提示:file not recognized: File format not recognized.

错误提示:

[email protected]:/# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ mysql-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 wont be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting mysql-python
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
  Building wheel for mysql-python (setup.py) ... error
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__=‘/tmp/pip-install-9DEpPZ/mysql-python/setup.py‘;f=getattr(tokenize, ‘open‘, open)(__file__);code=f.read().replace(‘
‘, ‘
‘);f.close();exec(compile(code, __file__, ‘exec‘))" bdist_wheel -d /tmp/pip-wheel-LPtLlk --python-tag cp27:
  running bdist_wheel
  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/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
  copying MySQLdb/connections.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/CR.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/ER.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
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  running build_ext
  building _mysql extension
  creating build/temp.linux-x86_64-2.7
  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/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
  gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lmariadbclient -lpthread -lz -lm -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
  /usr/lib/x86_64-linux-gnu/libmariadbclient.so: file not recognized: File format not recognized
  collect2: error: ld returned 1 exit status
  error: command gcc failed with exit status 1

问题原因以及解决方法:

原因大概是在使用DockerFile构建新的镜像时将原镜像污染了,导致原镜像部分文件出错,删除本地的镜像重新拉一下新的镜像就好了。

 

以上是关于Docker Python2.7容器中安装第三方库GCC提示:file not recognized: File format not recognized的主要内容,如果未能解决你的问题,请参考以下文章

在 Docker 中安装地理空间库

pip 无法在 Python 2.7、Windows 7 中安装模块

如何在高山容器中安装 Docker?

如何在python2.7中安装MySQLdb 在virtualenv中安装

docker 在容器中安装yum等软件

在 docker 容器中安装 PostgreSQL