Macos m系列芯片环境下python3安装mysqlclient系列问题

最近学习python3,在安装mysqlclient的时候遇到了一些问题,直接使用哦pip install mysqlclient 直接报错了,记录一下解决方案。

环境信息
设备:Macbook Pro m1
系统:macos Sequoia 15.3.2
最终成功的python版本:Python3.13.3
pip版本:25.0.1
最终系统环境下mysqlclient版本:2.2.7 -> 对应mysql-client: 8.0.42

直接执行命令安装: pip3 install mysqlclient,报错信息:

Collecting mysqlclientUsing cached mysqlclient-2.2.7.tar.gz (91 kB)Installing build dependencies ... doneGetting requirements to build wheel ... errorerror: subprocess-exited-with-error× Getting requirements to build wheel did not run successfully.│ exit code: 1╰─> [35 lines of output]/bin/sh: pkg-config: command not found/bin/sh: pkg-config: command not found/bin/sh: pkg-config: command not found/bin/sh: pkg-config: command not foundTrying pkg-config --exists mysqlclientCommand 'pkg-config --exists mysqlclient' returned non-zero exit status 127.Trying pkg-config --exists mariadbCommand 'pkg-config --exists mariadb' returned non-zero exit status 127.Trying pkg-config --exists libmariadbCommand 'pkg-config --exists libmariadb' returned non-zero exit status 127.Trying pkg-config --exists perconaserverclientCommand 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.Traceback (most recent call last):File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>main()~~~~^^File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in mainjson_out["return_val"] = hook(**hook_input["kwargs"])~~~~^^^^^^^^^^^^^^^^^^^^^^^^File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheelreturn hook(config_settings)File "/private/var/folders/pg/lcz_0brx7dl64hcxtkjtrn1c0000gp/T/pip-build-env-lqq7jo65/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheelreturn self._get_build_requires(config_settings, requirements=[])~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/private/var/folders/pg/lcz_0brx7dl64hcxtkjtrn1c0000gp/T/pip-build-env-lqq7jo65/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requiresself.run_setup()~~~~~~~~~~~~~~^^File "/private/var/folders/pg/lcz_0brx7dl64hcxtkjtrn1c0000gp/T/pip-build-env-lqq7jo65/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setupexec(code, locals())~~~~^^^^^^^^^^^^^^^^File "<string>", line 156, in <module>File "<string>", line 49, in get_config_posixFile "<string>", line 28, in find_package_nameException: 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.

看错误信息是少了pkg-config
执行命令:brew install pkg-config,也报错!!!

fatal: not in a git directory
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Running `brew update --auto-update`...
Warning: You are using macOS 15.
We do not provide support for this pre-release version.
It is expected behaviour that some formulae will fail to build in this pre-release version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.==> Fetching pkg-config
==> Downloading https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar
######################################################################## 100.0%
==> ./configure --prefix=/opt/homebrew/Cellar/pkg-config/0.29.2_3 --disable-host
==> make
Last 15 lines from /Users/nankexiansheng/Library/Logs/Homebrew/pkg-config/02.make:
gatomic.c:464:10: error: incompatible integer to pointer conversion passing 'gsize' (aka 'unsigned long') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]464 |   return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);|          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./gatomic.h:191:45: note: expanded from macro 'g_atomic_pointer_xor'191 |     (gsize) __sync_fetch_and_xor ((atomic), (val));                          \|                                             ^~~~~
4 errors generated.
make[6]: *** [libglib_2_0_la-gatomic.lo] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [all-recursive] Error 1
make[4]: *** [all] Error 2
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2Do not report this issue to Homebrew/brew or Homebrew/core!Error: You are using macOS 15.
We do not provide support for this pre-release version.
It is expected behaviour that some formulae will fail to build in this pre-release version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

解决方法:
mysqlclient安装
可以参考mysqlclient文档
首选确保你的macos已经安装配置好了brew,以及配置了国内源。

# 安装pkg-config
brew install pkg-config
注意:如果这里报错,先执行下brew install mysql;再执行brew install pkg-config命令
# 安装 mysql-client
brew install mysql-client@8.0
# 添加环境变量 在 ~/.zshrc 中添加下面这行
export PKG_CONFIG_PATH="$(brew --prefix)/opt/mysql-client@8.0/lib/pkgconfig"保存后 source ~/.zshrc 刷新环境变量通过 printenv 可以查看确认当前环境变量

接下来可以正常安装mysqlclient,这里我安装的是mysqlclient 2.2.7版本

注意⚠️:2.0.0 以上版本需要python3.8及以上才能兼容

pip3 install mysqlclient

如果正常安装完成,没有报错,进入当前python运行环境测试
在这里插入图片描述
如果能正常引入MySQLdb而没有报错,那么基本上算上顺利完成了。可以尝试在虚拟环境安装完依赖启动项目试试

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/77651.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

微信小程序-van-uploader的preview-size

preview-size支持数组格式 修改前修改后1、升级微信小程序里面的van版本:2、 重新构建npm3、重启微信开发工具 修改前 引用van组件的上传文件&#xff0c;设置预览图尺寸&#xff0c;刚开始设置的是preview-size“140”&#xff0c;出来的效果就是一个正方形。 修改后 1、升级…

2. 第一个网页:前端基础入门

第一个网页&#xff1a;前端基础入门 一、网页文件基础认知 1. 文件扩展名 .htm 或 .html 均为网页文件后缀&#xff0c;二者功能完全一致扩展名隐藏方法 系统设置 → 文件夹选项 → 查看 → 取消勾选「隐藏已知文件类型的扩展名」 二、前端发展简史 1. 浏览器战争与标准混…

云原生--核心组件-容器篇-7-Docker私有镜像仓库--Harbor

1、Harbor的定义与核心作用 定义&#xff1a; Harbor是由VMware开源的企业级容器镜像仓库系统&#xff0c;后捐赠给 CNCF (Cloud Native Computing Foundation)。它基于Docker Registry扩展了企业级功能&#xff0c;用于存储、分发和管理容器镜像&#xff08;如Docker、OCI标准…

Java项目与技术栈场景题深度解析

Java项目与技术栈场景题深度解析 在互联网大厂Java求职者的面试中&#xff0c;经常会被问到关于Java项目或技术栈的场景题。本文通过一个故事场景来展示这些问题的实际解决方案。 第一轮提问 面试官&#xff1a;马架构&#xff0c;欢迎来到我们公司的面试现场。请问您对Java…

SpringMVC 静态资源处理 mvc:default-servlet-handler

我们先来看看效果,当我把这一行注释掉的时候&#xff1a; 我们来看看页面&#xff1a; 现在我把注释去掉&#xff1a; 、 可以看到的是&#xff0c;这个时候又可以访问了 那么我们就可以想&#xff0c;这个 <mvc:default-servlet-handler />它控制着我们页面的访问…

【leetcode】最长公共子路径问题

滚动hash 滚动哈希&#xff08;rolling hash&#xff09;也叫 Rabin-Karp 字符串哈希算法&#xff0c;它是将某个字符串看成某个进制下的整数&#xff0c;并将其对应的十进制整数作为hash值。 滚动hash算法的推导 假设有一个长度为n的数组a[0],a[1],a[2],…a[n-1]&#xff0…

【Linux网络】:套接字之UDP

一、UDP和TCP协议 TCP &#xff08;Transmission Control Protocol 传输控制协议&#xff09;的特点&#xff1a; 传输层协议有连接&#xff08;在正式通信前要先建立连接&#xff09;可靠传输&#xff08;在内部帮我们做可靠传输工作&#xff09;面向字节流 UDP &#xff08;U…

React19 useOptimistic 用法

用法 乐观更新 发起异步请求时&#xff0c;先假设请求会成功立即更新 UI 给用户反馈若请求最终失败&#xff0c;再将 UI 恢复到之前的状态 const [optimisticState, addOptimistic] useOptimistic(state, updateFn) 参数 state&#xff1a;实际值&#xff0c;可以是 useSta…

Deepseek-v3+cline+vscode java自动化编程

1、Deepseek DeepSeek 充值后&#xff0c;创建apikey 2、vscode Visual Studio Code - Code Editing. Redefined 3、下载插件cline 4、配置deepeseek-v3 的密钥到cline 5、不可用 在开始的几次调用能正常使用起来&#xff0c;用了几次后&#xff0c;不能使用了&#xff0c;请求…

数据分析案例:环境数据分析

目录 数据分析案例&#xff1a;环境数据分析1. 项目背景2. 数据加载与预处理2.1 数据说明2.2 读取与清洗 3. 探索性数据分析&#xff08;EDA&#xff09;3.1 时序趋势3.2 日内变化3.3 气象与污染物相关性 4. 特征工程4.1 时间特征4.2 滞后与滚动统计4.3 目标变量 5. 模型构建与…

网络原理 - 8

目录 补充 网络层 IP 协议 基本概念&#xff1a; 协议头格式 地址管理 如何解决 IP 地址不够用呢&#xff1f;&#xff1f;&#xff1f; 1. 动态分配 IP 地址&#xff1a; 2. NAT 机制&#xff08;网络地址映射&#xff09; 3. IPv6 网段划分 一些特殊的 IP 地址 …

向量检索新选择:FastGPT + OceanBase,快速构建RAG

随着人工智能的快速发展&#xff0c;RAG&#xff08;Retrieval-Augmented Generation&#xff0c;检索增强生成&#xff09;技术日益受到关注。向量数据库作为 RAG 系统的核心基础设施&#xff0c;堪称 RAG 的“记忆中枢”&#xff0c;其性能直接关系到大模型生成内容的精准度与…

dify对接飞书云文档,并且将图片传入飞书文档

前面讲了如何让dify展示图片&#xff0c;但是如果想让智能体回答的带图片的内容生成个文档该怎么弄呢&#xff1f;今天来实践一下。 dify工具带的有飞书云文档&#xff0c;正好&#xff0c;咱们就利用飞书云文档。 1、首先配置飞书云文档的key跟secret 注意要开头左侧的权限&a…

Linux系统之设置开机启动运行桌面环境

Linux 开机运行级别介绍与 Ubuntu 桌面环境配置指南 一、Linux 开机运行级别(Runlevel) 在传统的 Linux 系统(如 SysV init 初始化系统)中,运行级别定义了系统启动时加载的服务和资源。常见的运行级别如下: 运行级别模式用途0Halt(停机模式)关闭系统1Single User Mode…

Spring Cloud Gateway配置双向SSL认证(完整指南)

本文将详细介绍如何为Spring Cloud Gateway配置双向SSL认证,包括证书生成、配置和使用。 目录结构 /my-gateway-project ├── /certs │ ├── ca.crt # 根证书 │ ├── ca.key # 根私钥 │ ├── gateway.crt # 网关证书 │ ├── …

【虚幻5蓝图Editor Utility Widget:创建高效模型材质自动匹配和资产管理工具,从3DMax到Unreal和Unity引擎_系列第二篇】

虚幻5蓝图Editor Utility Widget 一、基础框架搭建背景&#xff1a;1. 创建Editor Utility Widget2.根控件选择窗口3.界面功能定位与阶段4.查看继承树5.目标效果 二、模块化设计流程1.材质替换核心流程&#xff1a;2.完整代码如下 三、可视化界面UI布局1. 添加标题栏2. 构建滚动…

LabVIEW实现DMM与开关模块扫描测量

该程序基于 LabVIEW&#xff0c;用于控制数字万用表&#xff08;DMM&#xff09;与开关模块进行测量扫描。通过合理配置触发源、测量参数等&#xff0c;实现对多路信号的自动化测量与数据获取&#xff0c;在电子测试、工业测量等领域有广泛应用。 ​ 各步骤功能详解 开关模块…

OpenAvatarChat要解决UnicodeDecodeError

错误信息如下 ailed to import handler module client/h5_rendering_client/client_handler_lam Traceback (most recent call last):File "E:\Codes\Python\aigc\OpenAvatarChat\src\demo.py", line 82, in <module>main()File "E:\Codes\Python\aigc\O…

数据库中的主键(Primary Key)

数据库中的主键&#xff08;Primary Key&#xff09; 主键是数据库表中用于唯一标识每一行记录的一个或多个列的组合&#xff0c;是关系型数据库中的重要概念。 主键的核心特性 唯一性&#xff1a;主键值必须唯一&#xff0c;不能重复非空性&#xff1a;主键列不能包含NULL值…

MySQL 9.3 正式发布!备份、用户管理与开发支持迎来革命性升级

开源数据库领域的标杆产品MySQL迎来重大更新——MySQL 9.3正式发布&#xff01;作为企业级数据库的“扛把子”&#xff0c;此次版本更新聚焦备份效率、用户管理精细化、开发支持增强三大核心领域&#xff0c;同时在高可用性和性能优化上实现突破。以下为你逐一解读新版本的亮点…