質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

1回答

6673閲覧

macOSでPillowがインストールできない

shinueda

総合スコア11

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2020/11/29 14:17

編集2020/11/29 15:21

環境は以下の通りです。

  • macOS BigSur(バージョン 11.0.1)
  • python 3.8.2
  • xcode 12.2
  • pip 20.2.4
  • CPU 3 GHz 6コアIntel Core i5
  • zlib 1.2.11

エラーの内容

pip install pillow==7.2

対応しているバージョンを指定しても、以下のエラーが出ます。

Collecting pillow==7.2 Using cached Pillow-7.2.0.tar.gz (39.1 MB) Building wheels for collected packages: pillow Building wheel for pillow (setup.py) ... error ERROR: Command errored out with exit status 1: command: /Users/Main/dev/blog/myvenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py'"'"'; __file__='"'"'/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-wheel-zok3gouq cwd: /private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/ Complete output (170 lines): running bdist_wheel running build running build_py creating build ... ... ... writing manifest file 'src/Pillow.egg-info/SOURCES.txt' running build_ext The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html Traceback (most recent call last): File "/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py", line 864, in <module> setup( File "/Users/Main/dev/blog/myvenv/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup return distutils.core.setup(**attrs) File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/core.py", line 148, in setup dist.run_commands() File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/Users/Main/dev/blog/myvenv/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 290, in run self.run_command('build') File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/Users/Main/.pyenv/versions/3.8.2/lib/python3.8/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py", line 694, in build_extensions raise RequiredDependencyException(f) __main__.RequiredDependencyException: zlib During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py", line 918, in <module> raise RequiredDependencyException(msg) __main__.RequiredDependencyException: The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html ---------------------------------------- ERROR: Command errored out with exit status 1: /Users/Main/dev/blog/myvenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py'"'"'; __file__='"'"'/private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-install-90makenz/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hn/x4x637952sd1ml9n7z6b6wsw0000gn/T/pip-record-e18ozz8v/install-record.txt --single-version-externally-managed --compile --install-headers /Users/Main/dev/blog/myvenv/include/site/python3.8/pillow Check the logs for full command output.

こんなに長いエラーが吐き出されます。

試したこと

  • pythonのバージョンを変えて試す。(3.8.0、3.8.2、3.8.3)
  • sudoで試す。

ググってみても正解に辿りづけずに困っています、よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

meg_

2020/11/29 14:27

エラーメッセージに「zlib」とありますが、こちらはマシンにインストールされていますか?
shinueda

2020/11/29 14:48

ありがとございます。 zlib 1.2.11 インストールされています。
quickquip

2020/11/29 15:13 編集

Pythonをpyenvでインストールする時に、zlibが有効になるようにしましたか? (今はまだCFLAGSやLDFLAGSを明に指定しないとうまくビルドできないはずですが。参考 https://github.com/pyenv/pyenv/issues/1737#issuecomment-731672292 ) あとマシンのCPUが何かを書いた方がよいかと思います。(追記、IntelかApple Siliconのどちらか、という意味です)
quickquip

2020/11/29 15:08

> zlib 1.2.11 > > インストールされています。 どうやって表示したものですか?
shinueda

2020/11/29 15:24 編集

ありがとうございます。 pyenvでpythonをインストールする際に、添付URLの方法でインストールしていました。 CPUは、 3 GHz 6コアIntel Core i5 brew install zlibをして、インストールされていることを再確認してみました。
guest

回答1

0

ベストアンサー

macOS 11.0.1
python(venv) 3.9.0

shell

1pip install pillow==7.2

pillowのバージョンを指定すると同様のエラーでインストールできませんでした。

shell

1pip install pillow

バージョンを指定しなければ 8.0.1 がインストールできました。
ここでpillow-8.0.1 を削除。

shell

1pip uninstall pillow

pillow-8.0.1 を削除。
Unable to install on macOS Big Sur (zlib missing)

quickquipさんのコメントを拝見して、さらにこの記事を参考に zlib をインストール。

shell

1brew install zlib

zlib インストール後のメッセージに従って、環境変数を設定。

export LDFLAGS="-L/usr/local/opt/zlib/lib" export CPPFLAGS="-I/usr/local/opt/zlib/include" export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"

shell

1pip install wheel 2pip install pillow==7.2

インストールを確認

% pip show pillow Name: Pillow Version: 7.2.0 Summary: Python Imaging Library (Fork) Home-page: https://python-pillow.org Author: Alex Clark (PIL Fork Author) Author-email: aclark@python-pillow.org License: HPND Location: /Users/hoge/fuga/venv/lib/python3.9/site-packages Requires: Required-by:

投稿2020/12/01 02:15

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問