DRYな備忘録

Don't Repeat Yourself.

ImportError: No module named PIL【python】【pyenv】

問題

Traceback (most recent call last):
  File "hoge.py", line 1, in <module>
    from PIL import Image
ImportError: No module named PIL

oh...

「お使いの環境ではPILなんて名前のモジュール無いですよ」とのこと

PIL無いんか?

入れます

[15:15:33]cd
[15:15:33]cd proj/python/sample
[15:15:37] → python --version
Python 3.3.3
[15:15:39] → pyenv versions
  system
* 3.3.3 (set by /Users/otiai10/proj/python/sample/.python-version)
  test01
[15:15:44] → pyenv local test01
[15:15:53] → pyenv versions
  system
  3.3.3
* test01 (set by /Users/otiai10/proj/python/sample/.python-version)
[15:15:57] → python --version
Python 3.3.3
[15:16:01] → pip install pillow
Downloading/unpacking pillow
# 略
Successfully installed pillow
Cleaning up...
[15:18:16] → pip list
Pillow (2.2.2)
pip (1.4.1)
setuptools (0.9.6)
[15:18:20] → pyenv version
test01 (set by /Users/otiai10/proj/python/sample/.python-version)
[15:18:42] → python
Python 3.3.3 (default, Dec 18 2013, 13:55:06)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> exit()

おk

virtualenvするときにちょっとひっかかった

ベースにするバージョンに入ってるpipパッケージは作られたvirtualenvに受け継がれない

[15:30:29] → pyenv versions
  system
* 3.3.3 (set by /Users/otiai10/proj/python/sample/.python-version)
[15:30:33] → pip list
Pillow (2.2.2)
pip (1.4.1)
setuptools (2.0)
[15:30:37][15:30:37] → pyenv virtualenv 3.3.3 test02
Installing setuptools from https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py...
# 略
Successfully installed pip
Cleaning up...
[15:30:56] → pip list
Pillow (2.2.2)
pip (1.4.1)
setuptools (2.0)
[15:30:59] → pyenv versions
  system
* 3.3.3 (set by /Users/otiai10/proj/python/sample/.python-version)
  test02
[15:32:10] → pyenv local test02
[15:32:16] → pyenv versions
  system
  3.3.3
* test02 (set by /Users/otiai10/proj/python/sample/.python-version)
[15:32:19] → pip list
pip (1.4.1)
setuptools (0.9.6)
[15:32:22]

3.3.3環境にはあったけどtest02環境には無いよPillow

DRYな備忘録