【问题标题】:How can I fix an error installing mysqlclient on CloudLinux?如何解决在 CloudLinux 上安装 mysqlclient 的错误?
【发布时间】:2020-12-21 12:58:11
【问题描述】:

我正在尝试在具有 CloudLinux 许可证的 cpanel 上部署我的烧瓶应用程序,我需要一些模块,但是当我尝试安装 mysqlclient 和 flask-mysqldb 时出现错误,我发现人们有很多这个模块的问题,我已经看到了如何修复它,但是在 Ubuntu、Debian 等中......我想知道如何在 CloudLinux 中修复它,这是我输入 pip install mysqlclient 时出现的错误:

 ERROR: Command errored out with exit status 1:
   command: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import                                                                                                              sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlcli                                                                                                             ent/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/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-opkxp_ee
       cwd: /tmp/pip-install-oenqn_iu/mysqlclient/
  Complete output (29 lines):
  /opt/alt/python38/lib64/python3.8/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.8
  creating build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
  copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
  creating build/lib.linux-x86_64-3.8/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/co                                                                                                             nstants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/cons                                                                                                             tants
  copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constant                                                                                                             s
  copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constant                                                                                                             s
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/                                                                                                             constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/consta                                                                                                             nts
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/MySQLdb
  /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -Wno-unused-result -Wsign-compa                                                                                                             re -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURC                                                                                                             E -fPIC -fwrapv -fPIC -Dversion_info=(2,0,1,'final',0) -D__version__=2.0.1 -I/us                                                                                                             r/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python38/include/python3.8 -c                                                                                                              MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or dir                                                                                                             ectory
  error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status                                                                                                              1
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient

DEPRECATION: Could not build wheels for mysqlclient which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

 ERROR: Command errored out with exit status 1:
     command: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/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-jckn3ad2/install-record.txt --single-version-externally-managed --compile --install-headers /home/clouxlla/virtualenv/flask/3.8/include/site/python3.8/mysqlclient
         cwd: /tmp/pip-install-oenqn_iu/mysqlclient/
    Complete output (29 lines):
    /opt/alt/python38/lib64/python3.8/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.8
    creating build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
    creating build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/MySQLdb
    /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,1,'final',0) -D__version__=2.0.1 -I/usr/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python38/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/clouxlla/virtualenv/flask/3.8/bin/python3.8_bin -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oenqn_iu/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oenqn_iu/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-jckn3ad2/install-record.txt --single-version-externally-managed --compile --install-headers /home/clouxlla/virtualenv/flask/3.8/include/site/python3.8/mysqlclient Check the logs for full command output.

我该怎么办?提前谢谢大家。

【问题讨论】:

    标签: python flask pip mysql-python


    【解决方案1】:

    MySQL 提供了他们自己版本的 MySQL 适配器 - MySQL 连接器,这是一个使用 MySQL API 的全功能 python 模块,不依赖 C 模块,只使用标准 python 模块。

    它在 CloudLinux CageFS 中运行,无需安装任何模块或修改任何配置。

    您可以在此处阅读更多相关信息: https://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html

    【讨论】:

      猜你喜欢
      • 2022-06-29
      • 2019-10-20
      • 1970-01-01
      • 2015-04-16
      • 1970-01-01
      • 2018-12-06
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多