6
7

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.

Pythonで OSError: Python library not found: Python, libpython3.7m.dylib が出たときのメモ

Posted at

#はじめに
pyinstallerを使って.pyファイルを実行ファイルにしようとしたときに起きたエラーに関する自分用メモ。

#環境
macOS 10.14.3(Mojave)
pyenv 1.2.10
Python 3.7.1

#エラー

OSError: Python library not found: Python, libpython3.7m.dylib, .Python, libpython3.7.dylib
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.

* On Debian/Ubuntu, you would need to install Python development packages
  * apt-get install python3-dev
  * apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

#対処
pyenvでPythonをインストールするときに enable-shared オプションを付ける。

$ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.1

#補足
macOS MojaveのpyenvでPythonをインストールしようとすると、zlibがあるのに以下のようなエラーが出ることがある。

zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

##対処
Mojave用のmacOS SDK headerを手動でインストールする。

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
6
7
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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?