Django ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๊ณ , ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๊ฒฐ ๊ตฌ์„ฑ์„ ์œ„ํ•ด mysqlclient ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋˜ ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

ํ™˜๊ฒฝ

  • macOS Mojave 10.14.5
  • Python 3.7.3
  • pip 19.1.1 (Python 3.7)

๋ฌธ์ œ

ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜ ๋ช…๋ น์œผ๋กœ mysqlclient ํŒจํ‚ค์ง€ ์„ค์น˜๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

$ pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/df/8jqrf7b543z2ff2s0rhbq54c0000gn/T/pip-install-v5w8wcwf/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/private/var/folders/df/8jqrf7b543z2ff2s0rhbq54c0000gn/T/pip-install-v5w8wcwf/mysqlclient/setup_posix.py", line 53, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/df/8jqrf7b543z2ff2s0rhbq54c0000gn/T/pip-install-v5w8wcwf/mysqlclient/setup_posix.py", line 53, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/df/8jqrf7b543z2ff2s0rhbq54c0000gn/T/pip-install-v5w8wcwf/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 "python setup.py egg_info" failed with error code 1 in /private/var/folders/df/8jqrf7b543z2ff2s0rhbq54c0000gn/T/pip-install-v5w8wcwf/mysqlclient/

ํ•ด๊ฒฐ

๋จผ์ € mysqlclient ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

mysqlclient ๋ฌธ์„œ : mysqlclient - PyPI

ํ•„์š”ํ•œ ์˜์กด ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

$ brew install mysql-connector-c

์•ž์„œ ์„ค์น˜ํ•œ ์˜์กด ํŒจํ‚ค์ง€ MySQL Connector/C ์˜ ๊ธฐ๋ณธ ๊ตฌ์„ฑ์ด ๋ถ€์ •ํ™•ํ•ด์„œ ๋‚ด์šฉ์„ ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

mysql_config ๊ตฌ์„ฑ์„ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

$ which mysql_config                    # ํŒŒ์ผ์˜ ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค.
/usr/local/bin/mysql_config
$ sudo nano /usr/local/bin/mysql_config # ํŽธ์ง‘๊ธฐ๋กœ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

์•„๋ž˜ ๋‚ด์šฉ์„ ์ฐพ์•„์„œ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

on macOS, on or about line 112:

์›๋ณธ:

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

๋ณ€๊ฒฝ:

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

SSL ๊ด€๋ จ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์•„๋ž˜ ๋ช…๋ น์œผ๋กœ ์ •๋ณด๋ฅผ ํ™•์ธํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

$ brew info openssl

์ด์ œ mysqlclient ํŒจํ‚ค์ง€๋ฅผ ๋ฌธ์ œ์—†์ด ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... done
  Stored in directory: /Users/bbon/Library/Caches/pip/wheels/30/91/e0/2ee952bce05b1247807405c6710c6130e49468a5240ae27134
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2.post1