繁体   English   中英

pip3 install mysql-python 在 Mac 上失败

[英]pip3 install mysql-python is failing on Mac

有很多类似的问题,但他们都有不同的解决方案。 他们都不适合我。

我正在尝试为 Django 项目安装 Mysql 连接器,但出现以下错误。

首先我安装了最新版本的 Django。 然后用下面的代码安装mysql

brew install mysql - 工作正常。

然后这是我正在尝试安装连接器的代码。

pip3 mysql-python 之前使用easy_install mysql-python但它们都不起作用。

蟒蛇版本:3.8.0

Django 版本:2.2.7

MySql 版本:8.0.18

pip3 mysql-python给出了这个错误:

Collecting mysql-python Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip ERROR: Command errored out with exit status 1: command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/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 /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/pip-egg-info cwd: /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/ Complete output (7 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py", line 13, in <module> from setup_posix import get_config File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/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.

您正在安装错误的库,您应该使用mysqlclient

pip install mysqlclient

我在我的 Mac 上有一个使用它的 django 项目。

编辑

安装 pip 包时应该使用 virtualenv

这个命令对我有用

pip3 install mysqlclient==1.4.2.post1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM