美文网首页
MySQL-python安装错误 EnvironmentErro

MySQL-python安装错误 EnvironmentErro

作者: 小楼又春风 | 来源:发表于2018-08-01 09:42 被阅读0次

pip安装MySQL-python时出错如下所示:

Collecting MySQL-python
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 573kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/38/ks_15k_j12z8hr167yg78str0000gn/T/pip-install-KED5ib/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/38/ks_15k_j12z8hr167yg78str0000gn/T/pip-install-KED5ib/MySQL-python/

看样子是找不到mysql_config,试了下mysql是可以正常使用的,mysql_config却找不到路径。

自己的mysql安装后可执行文件路径是/usr/local/mysql/bin,执行vi ~/.bash_profile看了下环境变量,原来自己使用的下面的添加别名的方式来使用/usr/local/mysql/bin/mysql,而并没有添加mysql_config,所以是找不到mysql_config的,如下所示:

alias mysql="/usr/local/mysql/bin/mysql"
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

解决方案:在~/.bash_profile中添加环境变量

export PATH=$PATH:/usr/local/mysql/bin

然后source ~/.bash_profile让其生效即可

相关文章

网友评论

      本文标题:MySQL-python安装错误 EnvironmentErro

      本文链接:https://www.haomeiwen.com/subject/awrlvftx.html