请帮我修复错误 - mysqlclient

问题描述 投票:0回答:3

pip 安装 mysqlclient

Collecting mysqlclient
  Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      /bin/sh: 1: mysql_config: not found
      /bin/sh: 1: mariadb_config: not found
      /bin/sh: 1: mysql_config: not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup.py", line 15, in <module>
          metadata, options = get_config()
        File "/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup_posix.py", line 70, in get_config
          libs = mysql_config("libs")
        File "/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup_posix.py", line 31, in mysql_config
          raise OSError("{} not found".format(_mysql_config_path))
      OSError: mysql_config not found
      mysql_config --version
      mariadb_config --version
      mysql_config --libs
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

请帮我修复错误。

python-V

Python 3.9.2

点列表

套装版


22.3 点 pkg_资源 0.0.0 安装工具 65.5.0

mysql
3个回答
8
投票

谢谢。问题解决了

Linux 请注意,这是一个基本步骤。我不支持为所有环境构建完整的步骤。如果您看到一些错误,您应该自行修复它,或者在某些用户论坛中寻求支持。不要在问题跟踪器上提交问题。

您可能需要安装 Python 3 和 MySQL 开发标头和库,如下所示:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential 

Debian / Ubuntu

pip install mysqlclient

5
投票

您需要按照此软件包的安装说明进行操作。

https://pypi.org/project/mysqlclient/

听起来你在 OSX 上 - 你需要在那里安装 mysql。


0
投票

在 macOS 上安装 mysqlclient

如果您在

macOS
上遇到此错误,请首先使用
MySQL
安装
pkg-config
Homebrew
:

brew install mysql pkg-config

然后使用

mysqlclient
安装
pip
:

pip install mysqlclient

参考:GitHub 上的 mysqlclient 存储库

© www.soinside.com 2019 - 2024. All rights reserved.