1. 程式人生 > >Docker Python2.7容器中安裝第三方庫GCC提示:file not recognized: File format not recognized

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

-shared with comm get dock ... lec spa proto

問題描述:

在Docker容器中安裝Python第三方庫時提示:file not recognized: File format not recognized.

錯誤提示:

root@7c018aa445f4:/# 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(‘\r\n‘, ‘\n‘);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