Debian-box 和 pip3 安装

22 浏览
0 Comments

Debian-box 和 pip3 安装

我尝试使用 pip install 命令安装 MySQL-python 包,但遇到了 ImportError 错误。

Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
    Traceback (most recent call last):
      File "", line 16, in 
      File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in 
        from setup_posix import get_config
      File "./setup_posix.py", line 2, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
  File "", line 16, in 
  File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in 
    from setup_posix import get_config
  File "./setup_posix.py", line 2, in 
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$ 

有什么想法吗?

admin 更改状态以发布 2023年5月21日
0
0 Comments

在Python 3中,ConfigParser已经被重命名为configparser,以符合PEP 8标准。看起来您正在安装的包不支持Python 3。

0
0 Comments

您可以使用mysqlclient包代替MySQL-python。它是MySQL-python的一个分支,具有对Python 3的支持。

我在我的python3.4虚拟环境中仅仅用了

pip install mysqlclient

之后就好了

sudo apt-get install python3-dev libmysqlclient-dev

显然这仅针对于ubuntu/debian,但我只是想分享我的成功:)

0