当前位置:首页 > 操作系统 > MacOs

python-在Mac OS上使用django设置mysql

我正在尝试使用django应用程序设置mysql服务器,但是我无法正确安装它.

我用brew install mysql安装mysql服务器.

然后我用pip 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/r9/n0ld0jk57x590rzq5kv8x4wc0000gn/T/pip-build-ZZb7dn/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "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/r9/n0ld0jk57x590rzq5kv8x4wc0000gn/T/pip-build-ZZb7dn/mysqlclient/

也尝试过,pip安装MySQL-python,但它也给出相同的错误消息.

我在这里做错什么了吗?请引导我朝正确的方向发展,我最近从linux转向了mac os,我对这里的工作方式有些困惑.

注意:我正在尝试在虚拟环境中执行此操作.

解决方法:

对于Mac上的python3 django 1.11 mysql.这为我工作:

> brew安装mysql-connector-c
>编辑mysql_config(找到它:哪个mysql_config)

在mysql_config中更改以下内容:

# Create options #
libs="-L$pkglibdir"
libs="$libs -l "

至:

# Create options #
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

>酿造信息openssl
>最后pip3安装mysqlclient

并做了.


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!