走る
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
ランニング簡単インストールまたはそれを行うソースからどちらも最後に同じエラーが発生します (-lssl のライブラリが見つからない部分)。
brew install (またはupgrade) opensslを実行すると、以下の結果が得られます。
$ brew upgrade openssl
Error: openssl-1.0.1h already installed
誰か助けてくれませんか?
ベストアンサー1
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-cache
pipのオプションを使用する必要があるかもしれません。例:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install psycopg2
たとえば ARM/Apple M1 Mac でビルドする場合は、これらのパスを適宜調整することを忘れないでください (homebrew は にインストールされます/opt/homebrew/
)。次のようにコマンドを実行します。
env LDFLAGS="-I/opt/homebrew/opt/openssl/include -L/opt/homebrew/opt/openssl/lib" pip --no-cache install psycopg2