gpt4 book ai didi

python - 无法为 django/python3 安装 msqlclient [OSX 10.12.4]

转载 作者:行者123 更新时间:2023-11-29 19:04:16 27 4
gpt4 key购买 nike

当我运行python3 manage.py runserver时,我收到此消息:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. 
Did you install mysqlclient or MySQL-python?

因为我在 python 上使用 mysql 数据库,所以我尝试使用 pip3 安装 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/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/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/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup_posix.py", line 54, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup_posix.py", line 12, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/

我还在网上读到python3不支持mysqlclient,但是在尝试安装MySQL-python时我遇到了类似的错误:

 Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/

我如何解决这个问题并为 python 安装 mysql 客户端,或者是否有其他方法以便我可以在 python 中使用 MySQL db?

编辑:python3 支持 mysqlclient,但不支持 MySQL-python。

最佳答案

我不确定我做了什么,但我认为对我来说问题是我的 $PATH 不好。我试图执行我在 Google 上找到的步骤之一,在重置 bash_profile 并再次设置 Python 路径后,它已为我修复。

关于python - 无法为 django/python3 安装 msqlclient [OSX 10.12.4],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43629713/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com