求水之鱼 2025-01-21 20:28 采纳率: 0%
浏览 34

superset安装mysql驱动pip install mysqlclient报错,请问怎么解决?

通过docker安装superset后,成功启动容器,想安装mysql驱动,进入容器通过命令pip install mysqlclient后报错,报错如下,请问怎么解决啊?


superset@d85f4ee99aa0:/app$ pip install mysqlclient
Defaulting to user installation because normal site-packages is not writeable
Collecting mysqlclient
  Using cached mysqlclient-2.2.7.tar.gz (91 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      /bin/sh: 1: pkg-config: not found
      /bin/sh: 1: pkg-config: not found
      /bin/sh: 1: pkg-config: not found
      /bin/sh: 1: pkg-config: not found
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
      Trying pkg-config --exists libmariadb
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
      Trying pkg-config --exists perconaserverclient
      Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.
      Traceback (most recent call last):
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-48lijno9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/tmp/pip-build-env-48lijno9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-48lijno9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 156, in <module>
        File "<string>", line 49, in get_config_posix
        File "<string>", line 28, in find_package_name
      Exception: Can not find valid pkg-config name.
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.


  • 写回答

3条回答 默认 最新

  • 关注

    以下回复参考:皆我百晓生券券喵儿等免费微信小程序作答:

    从你提供的错误信息来看,问题出在安装mysqlclient时缺少必要的构建依赖,具体来说是缺少pkg-config工具。在Docker容器中安装mysqlclient可能会遇到这种问题,因为容器可能缺少某些系统依赖项。解决这个问题的方法是在Docker容器中安装pkg-config以及MySQL的开发库。

    你可以尝试以下步骤来解决这个问题:

    1. 进入Docker容器:
    docker exec -it <容器ID或名称> /bin/bash
    
    1. 安装pkg-config和MySQL的开发库。你可以使用以下命令(假设你的容器是基于Debian或Ubuntu的):
    apt-get update
    apt-get install -y pkg-config libmysqlclient-dev
    

    如果你使用的是其他类型的Linux基础镜像,可能需要使用不同的包管理器命令来安装这些依赖项。 3. 退出容器并重新尝试安装mysqlclient: 在容器外使用命令:

    pip install mysqlclient
    

    这样应该能够成功安装mysqlclient。如果仍然遇到问题,请提供更多关于你的Docker容器配置和使用的操作系统版本的信息,以便我能更准确地帮助你解决问题。

    评论

报告相同问题?

问题事件

  • 修改了问题 1月21日
  • 创建了问题 1月21日