~玉米糊~
慢慢来,也会很快。 非宁静无以志学,学什么都一样,慢慢打基础,找规律、认真、坚持,其余的交给时间。
随笔 - 117,  文章 - 17,  评论 - 1,  阅读 - 82072
基本版本信息
  • 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

  

posted on   yuminhu  阅读(2854)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5
点击右上角即可分享
微信分享提示