簡體   English   中英

在mac os上用django設置mysql

[英]setup mysql with django on mac os

我正在嘗試使用我的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 install MySQL-python但它也給出了相同的錯誤信息。

我在這里做錯了嗎? 請指導我正確的方向,我最近從linux轉移到mac os,我有點困惑這里的工作方式。

注意:我正在嘗試在virtual environment執行此操作。

對於mac上的python3 + django 1.11 + mysql。 這對我有用:

  1. brew install mysql-connector-c
  2. 編輯mysql_config(找到它: which mysql_config

在mysql_config中更改以下內容:

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

至:

# Create options #
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
  1. brew info openssl

  2. 最后pip3 install mysqlclient

並做了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM