ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

解决centos7安装mysqlclient的错误

2022-04-30 09:04:20  阅读:454  来源: 互联网

标签:config setup py mysqlclient centos7 install mysql 安装


基本版本信息
  • centos7.9
  • python3.8.6
  • django3.1.5

安装mysqlclient需要如下错误:

[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

添加软连接以后还是不行的话呢,再做如下操作:

# 先安装mysql-devel,后安装mysqlclient
yum install mysql-devel
pip3 install mysqlclient

  

完美解决问题

[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 

  

标签:config,setup,py,mysqlclient,centos7,install,mysql,安装
来源: https://www.cnblogs.com/yuminhu/p/16209403.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有