基本版本信息
- centos7.9
- python3.8.6
- django3.1.5
安装mysqlclient需要如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | [root@ 145 - 63 bseip - backend - admin] # pip3 install mysqlclient Looking in indexes: http: / / mirrors.aliyun.com / pypi / simple / Collecting mysqlclient Downloading http: / / mirrors.aliyun.com / pypi / packages / de / 79 / d02be3cb942afda6c99ca207858847572e38146eb73a7c4bfe3bdf154626 / mysqlclient - 2.1 . 0.tar .gz ( 87 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6 / 87.6 KB 193.8 kB / s eta 0 : 00 : 00 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: mysql_config: command not found / bin / sh: mariadb_config: command not found / bin / sh: mysql_config: command 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-5y7mr_zh/mysqlclient_179014460dd4451e9991237ca7ebcb86/setup.py" , line 15 , in <module> metadata, options = get_config() File "/tmp/pip-install-5y7mr_zh/mysqlclient_179014460dd4451e9991237ca7ebcb86/setup_posix.py" , line 70 , in get_config libs = mysql_config( "libs" ) File "/tmp/pip-install-5y7mr_zh/mysqlclient_179014460dd4451e9991237ca7ebcb86/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. |
错误信息可以看出来, mysql_config这个依赖包出现了问题。
解决问题:
添加软连接
ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
添加软连接以后还是不行的话呢,再做如下操作:
1 2 3 | # 先安装mysql-devel,后安装mysqlclient yum install mysql - devel pip3 install mysqlclient |
完美解决问题
1 2 3 4 5 6 7 8 9 | [root@ 145 - 63 bseip - backend - admin] # pip3 install mysqlclient Looking in indexes: http: / / mirrors.aliyun.com / pypi / simple / Collecting mysqlclient Using cached http: / / mirrors.aliyun.com / pypi / packages / de / 79 / d02be3cb942afda6c99ca207858847572e38146eb73a7c4bfe3bdf154626 / mysqlclient - 2.1 . 0.tar .gz ( 87 kB) Preparing metadata (setup.py) ... done Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed. Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... done Successfully installed mysqlclient - 2.1 . 0 |
分类:
linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!