安装MySQL-python错误

安装MySQL-python错误

我正在尝试安装 Python 包,但每次都出现错误。我在不同的网页上寻找解决方案,但没有一个能解决我的问题。我不知道是我做错了什么,还是问题出在其他地方

$ sudo pip install MySQL-python

Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip (108 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kmndmtdh/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kmndmtdh/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-kmndmtdh/MySQL-python/pip-egg-info
         cwd: /tmp/pip-install-kmndmtdh/MySQL-python/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-kmndmtdh/MySQL-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/tmp/pip-install-kmndmtdh/MySQL-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

错误消息:

错误_1

错误_2

答案1

您可以尝试以下步骤,我曾使用这些步骤来安装“mysql-python”,

  1. 安装python2.7

    (base) [test@localhost ~]$ conda install python=2.7
    
  2. 创建第二个环境(如果您希望直接创建 2.7 作为基础环境)

    (base) [test@localhost ~]$ conda create -n test_mysql python=2.7
    
  3. 激活刚刚创建的安装有python2.7的环境

    (base) [test@localhost ~]$ conda activate test_mysql
    
  4. 安装mysql-python在那种环境中

    (test_mysql) [test@localhost ~]$ conda install -c anaconda mysql-python
    
  5. 检查已安装的软件包

    (test_mysql) [test@localhost ~]$ conda list |grep -i mysql
    
    mysql-connector-c         6.1.11               h597af5e_1    anaconda
    
    mysql-python              1.2.5            py27h7b6447c_0    anaconda
    

相关内容