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.

macOSでpyenvで入れたpythonをPyCallで使うには

Last updated at Posted at 2017-01-29

背景

pyenvで入れたpython 3.6.0でGPUを有効にしたtensorflowを入れた。

それを、JuliaからPyCall経由で使うため、

ENV["PYTHON"]="/Users/foo/.pyenv/versions/3.6.0/bin/python"
Pkg.build("PyCall")

とPyCallをPYTHON環境変数を指定してリビルドして、

using PyCall

すると、

ImportError: No module named site

対策

pyenvで入れる際に、libpythonがスタティクリンクなのが原因の模様。
pyenv install時にCONFIGURE_OPTS="--enable-shared"と、libpythonを
ダイナミックリンク指定で作成するオプションを渡すことで対応できた。

CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.0

参考資料

関連記事

6
7
6

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?