Running setup.py install for psycopg2 ... error #M1 Mac #Django


`pip install psycopg2` 명령어로 psycopg2를 설치하려고 하는데 아래와 같은 에러 발생


Collecting psycopg2

Using cached psycopg2-2.8.6.tar.gz (383 kB)

Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.

Installing collected packages: psycopg2

Running setup.py install for psycopg2 ... error

...

ld: library not found for -lssl


확인해보니 openssl은 설치되어 있었지만 심볼릭 링크가 등록되어 있지 않아서 컴파일러가 대상을 찾지 못해 발생하는 에러였다.

`brew link openssl --force`를 실행하여 나열되는 항목들을 실행하여 심볼릭 링크를 등록한 후 psycopg2를 다시 설치해보자.


아래는 `brew link openssl --force`를 실행했을때 출력되는 예이다.

Warning: Refusing to link macOS provided/shadowed software: openssl@1.1

If you need to have openssl@1.1 first in your PATH, run:

echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:

export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"

export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:

export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"