安裝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. 安裝Python 2.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
    

相關內容