1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Djangoでmysqlclientをインストールしようとしたらerror: command 'gcc' failed with exit status 1と出た

Posted at

環境

macOS Catalina 10.15.4

エラーが出た!

新しく

python3 -m venv env

で仮想環境を構築してから

pip install mysqlclient

を実行したらタイトルのエラーにぶち当たる。

まず誰か先に同じエラーにぶちあたってる人いるでしょ!と思い調べてみると2パターンあるっぽくて、まず先のケースがこれ。

Cannot install Pillow in macOS Mojave using brew #3438

こちらの方はpillowをpipでインストールしようとしたらエラーを出したようで、その原因はmojaveによるものらしい。
それで、解決策としては

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

を実行したら私は出なくなりました!とのこと。しかし私の場合はこちらの手順を踏んでもエラーが解消されませんでした。
そもそもCatalinaにアップデートした方ではこの手順は不可能なようです。

もしかしたらこちらのパターンでうまくいく方もいらっしゃるかもしれないので書いておきます。

二つ目のケースがこれ。

pip install ができない件(error: command 'gcc' failed with exit status 1)

これで一旦Xcodeをダウンロード、インストールした後にもう一度

pip install mysqlclient

実行。

すると
ld: library not found for -lssl linker command failed with exit code 1 (use -v to see invocation)
とエラーが変わる。どうやらパスを通してないことが原因のようなので

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

を実行。

その後再びインストールしてみると成功。
うんうん悩みながらやってましたが無事解決できてよかったです。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?