“OSError:mysql_config找不到”当试图“点安装mysqlclient” - Django

我是相对较新的Django和一般的Web开发。“OSError:mysql_config找不到”当试图“点安装mysqlclient” - Django

我想

pip install mysqlclient 

在我

virtualenv -p python3 

到Django的2.0挂钩到MySQL。不过,我得到这个错误:

Collecting mysqlclient 

Using cached mysqlclient-1.3.12.tar.gz

Complete output from command python setup.py egg_info:

/bin/sh: mysql_config: command not found

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/private/var/folders/43/md5vpqrx0mx8627sq04slbz00000gn/T/pip-build-l8ea3vja/mysqlclient/setup.py", line 17, in <module>

metadata, options = get_config()

File "/private/var/folders/43/md5vpqrx0mx8627sq04slbz00000gn/T/pip-build-l8ea3vja/mysqlclient/setup_posix.py", line 44, in get_config

libs = mysql_config("libs_r")

File "/private/var/folders/43/md5vpqrx0mx8627sq04slbz00000gn/T/pip-build-l8ea3vja/mysqlclient/setup_posix.py", line 26, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/43/md5vpqrx0mx8627sq04slbz00000gn/T/pip-build-l8ea3vja/mysqlclient/

我已经环顾四周,寻找答案了几个小时,是的,我已经签出this和this,但似乎没有奏效。

任何帮助将不胜感激!

回答:

您应该克隆的mysql回购开始:

git clone https://github.com/PyMySQL/mysqlclient-python 

那么你将获得mysql-connector-c。您可以通过执行获得它:

brew install mysql-connector-c 

在文本编辑器,然后打开/usr/local/bin/mysql_config

从Github上issue:

有在mysql_config线,如下列:

# Create options 

libs="-L$pkglibdir"

libs="$libs -l "

它应该是:

#Create options 

libs="-L$pkglibdir"

libs="$libs -lmysqlclient -lssl -lcrypto"

保存该文件,并在那里换回来的目录,你下载回购。现在打开site.cfg文件。 取消注释(删除#)

#mysql_config = /usr/local/bin/mysql_config 

保存的是并运行:

python3 setup.py install 

以上是 “OSError:mysql_config找不到”当试图“点安装mysqlclient” - Django 的全部内容, 来源链接: utcz.com/qa/264274.html

回到顶部