请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Mac下 mysqlclient 安装不起

python manage.py makemigrateions
提示:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

pipenv install mysqlclient

(orm) ➜  ormtest git:(master) ✗ pipenv install mysqlclient      
Installing mysqlclient…
Adding mysqlclient to Pipfile's [packages]…
✔ Installation Succeeded 
Installing dependencies from Pipfile.lock (adfa5b)…
An error occurred while installing mysqlclient==1.4.5 --hash=sha256:5c008e74b1c4a42271172c35f28a698cf79a7cba5d2bc811125e963f28001c34 --hash=sha256:6ad22de8ea3aba03ce1b202ed175e0c7a8b82fcdab8f57b1649c596550ed785a --hash=sha256:a66a7a5f4ec71e8952e27a91a3fa8e0a3ab0682e223f1a007a77518058d0d1b5 --hash=sha256:e80109b0ae8d952b900b31b623181532e5e89376d707dcbeb63f99e69cefe559! Will try again.
An error occurred while installing psycopg2==2.8.4 --hash=sha256:47fc642bf6f427805daf52d6e52619fe0637648fe27017062d898f3bf891419d --hash=sha256:72772181d9bad1fa349792a1e7384dde56742c14af2b9986013eb94a240f005b --hash=sha256:8396be6e5ff844282d4d49b81631772f80dabae5658d432202faf101f5283b7c --hash=sha256:893c11064b347b24ecdd277a094413e1954f8a4e8cdaf7ffbe7ca3db87c103f0 --hash=sha256:965c4c93e33e6984d8031f74e51227bd755376a9df6993774fd5b6fb3288b1f4 --hash=sha256:9ab75e0b2820880ae24b7136c4d230383e07db014456a476d096591172569c38 --hash=sha256:b0845e3bdd4aa18dc2f9b6fb78fbd3d9d371ad167fd6d1b7ad01c0a6cdad4fc6 --hash=sha256:dca2d7203f0dfce8ea4b3efd668f8ea65cd2b35112638e488a4c12594015f67b --hash=sha256:ed686e5926929887e2c7ae0a700e32c6129abb798b4ad2b846e933de21508151 --hash=sha256:ef6df7e14698e79c59c7ee7cf94cd62e5b869db369ed4b1b8f7b729ea825712a --hash=sha256:f898e5cc0a662a9e12bde6f931263a1bbd350cfb18e1d5336a12927851825bb6! Will try again.
 ?   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:17
Installing initially failed dependencies…
 ☤  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:19
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
[pipenv.exceptions.InstallError]:       editable_packages=state.installstate.editables,
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.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/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 862, in do_install_dependencies
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, False, failed_deps_queue, retry=False)
[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/', 'Collecting mysqlclient==1.4.5', '  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f8/9b/5db9a03e2088a87c26e3e4d4c7f7e8f4c2dbae610f9521cdfac15755a795/mysqlclient-1.4.5.tar.gz']
[pipenv.exceptions.InstallError]: ['ERROR: Command errored out with exit status 1:', '     command: /Users/cpx/.local/share/virtualenvs/orm-48K94PtH/bin/python3.7 -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/setup.py\'"\'"\'; __file__=\'"\'"\'/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/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/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/pip-egg-info', '         cwd: /private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/', '    Complete output (11 lines):', '    Traceback (most recent call last):', '      File "<string>", line 1, in <module>', '      File "/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/setup.py", line 16, in <module>', '        metadata, options = get_config()', '      File "/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/setup_posix.py", line 63, in get_config', "        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]", '      File "/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/setup_posix.py", line 63, in <listcomp>', "        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]", '      File "/private/var/folders/kx/7nvrgwzj187624t42xn8vqtm0000gn/T/pip-install-ojkp37zk/mysqlclient/setup_posix.py", line 12, in dequote', '        raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")', '    Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?', '    ----------------------------------------', 'ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.']
ERROR: ERROR: Package installation failed...

正在回答 回答被采纳积分+3

2回答

秋荏苒 2019-11-17 15:41:10

建议看下这篇文章

https://medium.com/@shandou/pipenv-install-mysqlclient-on-macosx-7c253b0112f2

Mac 安装 Mysql 并配置好 Mysql 真的有点麻烦

0 回复 有任何疑惑可以回复我~
  • 简单来说,就是因为苹果不使用 openssl 协议了,导致很多依赖这个协议的包无法正常安装,所以只需要安装上 openssl 之后,简单配置一下即可
    回复 有任何疑惑可以回复我~ 2019-11-17 15:59:37
deweizhang 2019-11-10 12:20:22

1 本机是否安装了mysql 如果没安装需要先安装mysql 再安装python的mysqlsdk
2 使用pip3 也就是python3下的pip安装 。判断当前pip是不是3的可以通过下面命令确认
pip -V

0 回复 有任何疑惑可以回复我~
  • 老师windows遇到同样的问题
    回复 有任何疑惑可以回复我~ 2020-02-15 14:55:57
  • https://blog.csdn.net/songlh1234/article/details/82664604。看下这个帖子 另外注意pip必须是python3版本 可以看上边的解答
    回复 有任何疑惑可以回复我~ 2020-02-15 14:58:14
  • 老师装完还是输入 python manage.py  makemigratiions,还是出现django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
    回复 有任何疑惑可以回复我~ 2020-02-15 15:56:59
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信