问题描述:
在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 won‘t 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构建新的镜像时将原镜像污染了,导致原镜像部分文件出错,删除本地的镜像重新拉一下新的镜像就好了。
原文地址:https://www.cnblogs.com/l33klin/p/10329165.html
时间: 2024-10-04 13:49:33