简体   繁体   English

pip3 install mysql-python 在 Mac 上失败

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

There are a lot of similar question but all of them has different solution.有很多类似的问题,但他们都有不同的解决方案。 And none of them work for me.他们都不适合我。

I'm trying to install Mysql connector for Django project but it gives below error.我正在尝试为 Django 项目安装 Mysql 连接器,但出现以下错误。

First I have installed latest version of Django.首先我安装了最新版本的 Django。 Then install mysql with below code然后用下面的代码安装mysql

brew install mysql - Worked fine. brew install mysql - 工作正常。

Then this is the code which I'm trying install connector.然后这是我正在尝试安装连接器的代码。

pip3 mysql-python . pip3 mysql-python Was using easy_install mysql-python before but both of them are not working.之前使用easy_install mysql-python但它们都不起作用。

Python Version: 3.8.0蟒蛇版本:3.8.0

Django Version: 2.2.7 Django 版本:2.2.7

MySql Version: 8.0.18 MySql 版本:8.0.18

pip3 mysql-python gives this error: 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.

You're installing the wrong lib, you should be using mysqlclient .您正在安装错误的库,您应该使用mysqlclient

pip install mysqlclient

I have a django project on my Mac using it.我在我的 Mac 上有一个使用它的 django 项目。

Edit编辑

You should be using virtualenv when installing pip packages.安装 pip 包时应该使用 virtualenv

This command worked for me这个命令对我有用

pip3 install mysqlclient==1.4.2.post1

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

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