[python] psycopg2 설치 오류, -lssl에 대한 라이브러리를 찾을 수 없음

난 달린다

sudo pip install psycopg2

다음과 같은 출력을 얻습니다.

cc -DNDEBUG -g -fwrapv -Os .....
.....
cc -DNDEBUG -g -fwrapv -Os .....
.....

그리고 마지막에는 다음과 같이 말합니다.

ld: library not found for -lssl

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command 'cc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip_build_root/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip-uE3thn-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip_build_root/psycopg2
Storing debug log for failure in /Users/Tyler/Library/Logs/pip.log

easy_install을 실행 하거나 소스 에서 수행하면 끝에 동일한 오류가 발생합니다 (-lssl에 대한 라이브러리를 찾을 수 없음).


brew install (또는 업그레이드) openssl을 실행하면 아래와 같은 결과가 나옵니다.

$ brew upgrade openssl
Error: openssl-1.0.1h already installed

누구든지 나를 도울 수 있습니까?



답변

macOS Sierra 10.12 (또는 그 이상)에서 이에 대한 솔루션을 찾는 모든 사람 : 명령 줄 도구를 설치하여이 문제를 해결했습니다.

xcode-select --install

그 후에 pip install psycopg2작동합니다.

그렇지 않은 경우 brew의 openssl에 대해 링크를 시도 할 수도 있습니다.

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2

brew를 통해 설치된 openssl과 함께. (가) 있습니다 brew link openssl --force더 이상 작동하지 않습니다

$ brew link openssl --force                                                                                 17.5s
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

@macho가 여전히 작동하지 않으면 아래에서 지적했듯이 --no-cachepip 옵션 을 사용해야 할 수도 있습니다.

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install psycopg2


답변

Brew ( brew install openssl) 에서 OpenSSL을 설치했습니다.

다음은 나를 위해 일했습니다.

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install psycopg2


답변

실행할 때 brew link openssl다음 메시지가 나타납니다.

$ brew link openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

이 조언에 따라 pip사용해야 하는 명령 은 다음과 같습니다 .

$ pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"


답변

MacOS Catalina 10.15.4에서 다음은 나를 위해 일한 유일한 명령이었습니다.

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2


답변

나를 위해 일한 것은 openssl을 연결하는 명령에 제공된 힌트였습니다.

$ brew link openssl
Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"

$ pip install psycopg2
Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/23/7e/93c325482c328619870b6cd09370f6dbe1148283daca65115cd63642e60f/psycopg2-2.8.2.tar.gz
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.2


답변

mojave에서 나는 이것을 .bash_profile에 추가했습니다.

export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/curl/lib -L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include -I/user/local/opt/openssl/include"

그런 다음 파이썬 3.7.4 virtualenv에 psycopg 2.8.3을 설치할 수있었습니다.

xcode 및 명령 줄 도구를 다시 설치 한 후.

위의 모든 답변이 도움이되었습니다!


답변

이것은 pip가 .NET을 설치할 수없는 새로운 macOs 버전의 문제입니다 cryptography. 내 문제를 해결 한 것은 설치 명령에 env를 제공하는 것입니다.

brew install openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" <YOUR COMMAND HERE>

당신은 대체 할 수 <YOUR COMMAND HERE>와 함께 pip install cryptography, 또는 pip install <SOMETHING THAT REQUIRES cryptography>예를 들어.

이 기사에 대한 크레딧 : macOS Sierra 치명적인 오류 수정 : ‘openssl / opensslv.h’또는 ‘openssl / aes.h’파일을 찾을 수 없음