pip3 install mysql-python 的一些问题

安装mysql-python的时候

提示报错:

ModuleNotFoundError: No module named 'ConfigParser'

原因:

在 Python 3.x 版本后,ConfigParser.py 已经更名为 configparser.py 所以出错!

解决办法:复制一份即可

sudo cp /usr/local/lib/python3.6/configparser.py /usr/local/lib/python3.6/ConfigParser.py

再次安装:

[cloud@Seewo-PortraitLibrary ~]$ pip3 install --user mysql
Collecting mysql
  Downloading https://mirrors.aliyun.com/pypi/packages/06/ef/c4efbf2a51fb46aba9be03a973638d9539c9ca10a5259b2cbb1a66133b2e/mysql-0.0.1.tar.gz
Collecting MySQL-python (from mysql)
  Downloading https://mirrors.aliyun.com/pypi/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 597kB/s
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-build-5rkff6id/MySQL-python/setup.py", line 17, in 
        metadata, options = get_config()
      File "/tmp/pip-build-5rkff6id/MySQL-python/setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-build-5rkff6id/MySQL-python/setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found

仍然报错哈(生无可恋脸):

OSError: mysql_config not found

搜了下大概是需要补充如下包 ,然后mysql_config 这个环境变量以及内容就会自动有

sudo yum install mysql-devel gcc gcc-devel python-devel

其实主要是 mysql-devel,其余的也很常见就顺带一起安装了

重新输入,问题解决

$ pip3 install --user mysql-python
Collecting mysql-python
  Downloading https://mirrors.aliyun.com/pypi/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 943kB/s
Installing collected packages: mysql-python
  Running setup.py install for mysql-python ... done
Successfully installed mysql-python-1.2.5

好像还有别的问题,不过应该不属于这里了,再讨论。

你可能感兴趣的:(pip3 install mysql-python 的一些问题)