我为django 1.9项目创建了virtualenv.我试图pip安装mysqlclient或mysql-python但他们两个都给我错误.
pip install mysqlclient
pip install mysql-python
两个都给我相同的错误信息:
命令"python setup.py egg_info"失败,错误代码为1/private/var/folders/r4/bkv_4t9s4r140pjkgv6lsq8w0000gn/T/pip-build-cdxcssp9/mysqlclient
有什么建议!?
尝试在Python 3.6.0上使用pip3安装mysqlclient
$ pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.10.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 12, in dequote
        if s[0] in "\"'" and …我正在使用 django 和 mysql。
要与 mysql 通信 django,必须安装 mysqlclient。
另外python版本是3.7.2
pipenv install mysqlclient
它会引发错误。
Installing mysqlclient...
? Installation Succeeded 
Pipfile.lock (c98c3a) out of date, updating to (a65489)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
? Success! 
Updated Pipfile.lock (c98c3a)!
Installing dependencies from Pipfile.lock (c98c3a)...
An error occurred while installing mysqlclient==1.4.2.post1 --hash=sha256:425e733b05e359a714d6007c0fc44582be66b63e5a3df0a50949274ae16f4bc6 --hash=sha256:62e4770b6a797b9416bcf70488365b7d6b9c9066878108499c559293bb464380 --hash=sha256:f257d250f2675d0ef99bd318906f3cfc05cef4a2f385ea695ff32a3f04b9f9a7! Will try again.
     ???????????????????????????????? 1/1 — 00:00:02
Installing initially failed dependencies...
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python2.7/site-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]:       skip_lock=skip_lock,
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python2.7/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]: …我正在尝试从 django 应用程序连接到我的 mysql 数据库。我在迁移过程中收到以下错误:
django.core.exceptions.ImproperlyConfigured:加载 MySQLdb 模块时出错。你安装了mysqlclient吗?
我已经安装了 mysqlclient 如下:
需求已经满足:mysqlclient in /usr/local/lib/python3.7/site-packages (1.4.2.post1)
我也尝试过使用 pymysql 并将以下代码添加到ini .py 文件中:
import pymysql
pymysql.install_as_MySQLdb()
给我一些其他错误。可能有什么问题?
Python 3.7 、 mysql 5.7 和 Django 2.2 是我的安装版本。
python ×3
django ×2
mysql ×2
python-3.x ×2
macos ×1
macos-sierra ×1
mysql-python ×1
pip ×1
pipenv ×1
virtualenv ×1