安装mysqlclient时报错

安装mysqlclient时报错

报错内容:


pip install mysqlclient

Collecting mysqlclient

  Using cached mysqlclient-2.1.1.tar.gz (88 kB)

  Preparing metadata (setup.py) ... error

  error: subprocess-exited-with-error

  

  × python setup.py egg_info did not run successfully.

  │ exit code: 1

  ╰─> [18 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 "/private/var/folders/pc/4rdxcdhx4cg_sz00rxkf499h0000gn/T/pip-install-pzzaabno/mysqlclient_85fc99e846cf49e89a537e47d94f2bda/setup.py", line 15, in <module>

          metadata, options = get_config()

                              ^^^^^^^^^^^^

        File "/private/var/folders/pc/4rdxcdhx4cg_sz00rxkf499h0000gn/T/pip-install-pzzaabno/mysqlclient_85fc99e846cf49e89a537e47d94f2bda/setup_posix.py", line 70, in get_config

          libs = mysql_config("libs")

                 ^^^^^^^^^^^^^^^^^^^^

        File "/private/var/folders/pc/4rdxcdhx4cg_sz00rxkf499h0000gn/T/pip-install-pzzaabno/mysqlclient_85fc99e846cf49e89a537e47d94f2bda/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.


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
QXY_DZ 提问者 2023-04-12 11:14:32
安装了pymysql之后就不用安装MySQLclient了吗?
  • 同学,你好!是的,不需要安装mysqlclient了。同学可以跟着视频操作,视频用到哪些软件安装哪些软件就可以的。

    祝学习愉快~

    2023-04-12 12:08:51
  • 提问者 QXY_DZ 回复 好帮手慕小猿 #2

    视频中就提到了MySQLclient

    2023-04-12 14:07:27
  • 好帮手慕小猿 回复 提问者 QXY_DZ #3

    同学,你好!同学尝试以下步骤看能否安装成功

    1、使用brew 安装mysql-client。若没有brew ,先安装brew,命令如下:

    /usr/bin/ruby -e "$(curl -fsSL

    安装完成brew后再安装mysql-client

    brew install mysql-client


    2、找到mysql-client安装路径

    #通过以下命令找到mysql-client的相关位置,输入命令:
    locate mysql-client
     
    每个电脑输出目录可能不同,如老师的是:
    /opt/homebrew/Cellar/mysql-client/8.0.30/bin

    3、配置环境变量

    #打开.zshrc文件
    open .zshrc
     
    #配置环境变量,添加以下路径到zshrc文件下
    export PATH="/opt/homebrew/Cellar/mysql-client/8.0.30/bin:$PATH"

    4、安装myqlclient

    pip install mysqlclient


    祝学习愉快~

    2023-04-12 14:39:57
好帮手慕小猿 2023-04-12 11:06:28

同学,你好!同学应该安装pymysql  ,即pip install pymysql

祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师