无法在 linux 共享主机服务器上安装 'mysqlclient'。 'Failed to build wheel for mysqlclient'
Unable to install 'mysqlclient' on linux shared hosting server. 'Failed to build wheel for mysqlclient'
我在本地开发了一个Django App (django版本-3.0.5,python版本3.8.2,OS-Windows10)。
在我的本地服务器上,我使用以下命令安装了 'mysqlclient'。
python -m pip install mysqlclient
该应用程序在我的本地服务器上完全正常运行。我为生产部署购买了共享主机。它是一个 linux 服务器(django 版本 - 3.0.5,python 版本 3.7.3)。我在 virtualenv 上安装了 Django 和 Python,但无法安装 'mysqlclient'。我使用了以下命令。
pip install mysqlclient
显示错误如下:
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-y99lbq6b
cwd: /tmp/pip-install-l6dot083/mysqlclient/
Complete output (34 lines):
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
creating build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
unable to execute 'gcc': Permission denied
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-1a81g6q6/install-record.txt --single-version-externally-managed --compile --install-headers /home/testdev/virtualenv/test/3.7/include/site/python3.7/mysqlclient
cwd: /tmp/pip-install-l6dot083/mysqlclient/
Complete output (34 lines):
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
creating build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
unable to execute 'gcc': Permission denied
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-1a81g6q6/install-record.txt --single-version-externally-managed --compile --install-headers /home/testdev/virtualenv/test/3.7/include/site/python3.7/mysqlclient Check the logs for full command output.
我尝试了以下方案作为解决方案,但没有奏效。
- 升级'pip'版本
- 升级'wheel'版本
- 试图通过Github
安装包
pip install MySQL-python
并得到 (ModuleNotFoundError)
pip3 install MySQL-python
得到同样的错误
(注意: 'sudo' 或 'apt' 命令无效。
我不允许使用非官方的 mysqlclient 包。
这个问题的解决方案是什么?
或者如何在没有 mysqlclient 包的情况下将我的应用程序连接到数据库?
问题由服务商解决。他们能够使用他们的管理员权限安装 mysqlclient。
我在本地开发了一个Django App (django版本-3.0.5,python版本3.8.2,OS-Windows10)。 在我的本地服务器上,我使用以下命令安装了 'mysqlclient'。
python -m pip install mysqlclient
该应用程序在我的本地服务器上完全正常运行。我为生产部署购买了共享主机。它是一个 linux 服务器(django 版本 - 3.0.5,python 版本 3.7.3)。我在 virtualenv 上安装了 Django 和 Python,但无法安装 'mysqlclient'。我使用了以下命令。
pip install mysqlclient
显示错误如下:
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-y99lbq6b
cwd: /tmp/pip-install-l6dot083/mysqlclient/
Complete output (34 lines):
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
creating build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
unable to execute 'gcc': Permission denied
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-1a81g6q6/install-record.txt --single-version-externally-managed --compile --install-headers /home/testdev/virtualenv/test/3.7/include/site/python3.7/mysqlclient
cwd: /tmp/pip-install-l6dot083/mysqlclient/
Complete output (34 lines):
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/bin/mysql_config: line 8: rpm: command not found
/opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
creating build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
unable to execute 'gcc': Permission denied
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/testdev/virtualenv/test/3.7/bin/python3.7_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6dot083/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6dot083/mysqlclient/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-1a81g6q6/install-record.txt --single-version-externally-managed --compile --install-headers /home/testdev/virtualenv/test/3.7/include/site/python3.7/mysqlclient Check the logs for full command output.
我尝试了以下方案作为解决方案,但没有奏效。
- 升级'pip'版本
- 升级'wheel'版本
- 试图通过Github 安装包
pip install MySQL-python
并得到 (ModuleNotFoundError)pip3 install MySQL-python
得到同样的错误
(注意: 'sudo' 或 'apt' 命令无效。
我不允许使用非官方的 mysqlclient 包。
这个问题的解决方案是什么?
或者如何在没有 mysqlclient 包的情况下将我的应用程序连接到数据库?
问题由服务商解决。他们能够使用他们的管理员权限安装 mysqlclient。