Centos7使用pip安装mysqlclient时报错Exception: Can not find valid pkg-config name.

Defaulting to user installation because normal site-packages is not writeable
Collecting mysqlclient
  Using cached mysqlclient-2.2.0.tar.gz (89 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
  ╰─> [25 lines of output]
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 154, in <module>
          ext_options = get_config_posix(get_options())
        File "setup.py", line 48, in get_config_posix
          pkg_name = find_package_name()
        File "setup.py", line 27, in find_package_name
          raise Exception(
      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.

这个错误是在使用pip安装mysqlclient时报错,意思是无法通过pkg-config找到MySQL的相关库,可能因没有设置mysql的环境变量MYSQLCLIENT_CFLAGS和 MYSQLCLIENT_LDFLAGS。所以需要手动指定MySQL的头文件和库路径:

推荐查看此教程来安装MySQL数据库

CentOS7配置python和django项目开发环境(MySQL8.0+python3.9)-CSDN博客文章浏览阅读1.2k次,点赞39次,收藏24次。先更新一下系统。https://blog.csdn.net/qq_51261687/article/details/135232656?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22135232656%22%2C%22source%22%3A%22qq_51261687%22%7D前提需要已经安装了mysql数据库

  1. 1. 进入root模式,安装MySQL开发包

yum install mysql-devel
  1. 2. 设置环境变量

  • 编辑/etc/profile文件
vi /etc/profile

在文末补充添加以下行:

export MYSQLCLIENT_CFLAGS="-I/usr/include/mysql"
export MYSQLCLIENT_LDFLAGS="-L/usr/lib64/mysql"
  • 保存并关闭文件。
  • 重新加载/etc/profile文件,使更改生效:
source /etc/profile
  1. 3. 重新安装mysqlclient

pip install mysqlclient

  • 10
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
答案: 为了通过pkg-config工具找到x264库,你可以在命令行中使用"pkg-config --libs x264"或"pkg-config --cflags x264"命令。这些命令将返回与x264库相关的编译和链接选项,以供编译和连接程序使用。确保在使用pkg-config之前,你已经安装了x264库,并且库中包含了相应的.pc文件。此外,你可能需要设置PKG_CONFIG_PATH环境变量,将库的.pc文件路径添加到其中,以便pkg-config能够找到这些文件。例如,你可以使用以下命令设置PKG_CONFIG_PATH环境变量: export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/share/pkgconfig 然后,你可以使用"pkg-config --version"命令验证pkg-config是否成功设置和安装123 #### 引用[.reference_title] - *1* *2* [编译源码pkg-config报错问题(configure\pkg-config\PKG_CONFIG_PATH关系)](https://blog.csdn.net/weixin_43269452/article/details/113468490)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *3* [pkg-config --cflags -- vips vips vips vipspkg-config: exec: “pkg-config“: executab的解决方案centos...](https://blog.csdn.net/HYZX_9987/article/details/128736579)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代麻花

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值