我使用python vitrualenv,并且当我想通过pip install <package name>
安装任何软件包时,都会出现该错误:
ERROR: Command errored out with exit status 1:
command: /home/user/project/some_project_name/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sifdsjjx/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sifdsjjx/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-sifdsjjx/MySQL-python/pip-egg-info
cwd: /tmp/pip-install-sifdsjjx/MySQL-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-sifdsjjx/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-install-sifdsjjx/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.
我使用python 3.7.0 点20.0.2
答案 0 :(得分:6)
尝试升级setuptools
:
pip install --upgrade setuptools
更新
如评论中所述,您正在尝试安装MySQL-python
,这是一个非常旧的软件包(最新版本是2014年制作的)。
但是,您可以安装一个更新的版本,称为MySQLdb
,它是对C模块的瘦Python包装,该模块实现了MySQL数据库的API:
pip install mysqlclient
答案 1 :(得分:1)
您是否在系统上安装了SQL客户端dev pacakge?
sudo apt install libmysqlclient-dev
如果您使用的是mariadb,请替换为mysql,然后运行
sudo apt install libmariadbclient-dev
然后重试