安装枕头但仍然得到:ModuleNotFoundError:没有名为'PIL'的模块

时间:2018-01-14 12:10:50

标签: python macos pip python-imaging-library pillow

我试图在我的Mac上构建Fisherfaces(https://github.com/bytefish/facerec)(OS X 10.12.6),并且我成功地构建了它的依赖项,包括sklearn,numpy,scipy,matplotlib,除了Pillow。

所以我试过了: pip3 install Pillow 起初我失败了一些网络问题,所以我再次尝试,最后,我从终端得到了这个:

Installing collected packages: pillow
Successfully installed pillow-5.0.0

然后我尝试了终端:

TreaserdeMacBook-Pro:scripts treasersmac$ python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PIL'

当我使用python而不是python3时,仍然会得到同样的问题。

然后我查看pip3列表:

TreaserdeMacBook-Pro:scripts treasersmac$ pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
cycler (0.10.0)
Django (2.0.1)
image (1.5.17)
matplotlib (2.0.0)
nose (1.3.7)
numpy (1.12.0)
Pillow (5.0.0)
pip (9.0.1)
pygal (1.7.0)
pyparsing (2.1.10)
python-dateutil (2.6.0)
pytz (2016.10)
requests (2.13.0)
scikit-learn (0.19.1)
setuptools (36.5.0)
six (1.10.0)
wheel (0.30.0)

似乎没问题。

然后我检查了路径:

>>> import sys
>>> print(sys.path)
['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Users/treasersmac/Library/Python/3.6/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']

和PIL或Pillow在: /usr/local/lib/python3.6/site-packages

但:

TreaserdeMacBook-Pro:scripts treasersmac$ cd /usr/local/lib/python3.6/site-packages
TreaserdeMacBook-Pro:site-packages treasersmac$ ls
Django-2.0.1.dist-info          numpy-1.13.3-py3.6.egg-info
PIL                 pip
Pillow-5.0.0.dist-info          pip-9.0.1-py3.6.egg-info
__pycache__             pkg_resources
cv2.cpython-36m-darwin.so       scikit_learn-0.19.1.dist-info
django                  setuptools
easy_install.py             setuptools-36.5.0-py3.6.egg-info
homebrew-numpy-nose.pth         sitecustomize.py
image                   sklearn
image-1.5.17.dist-info          wheel
numpy                   wheel-0.30.0-py3.6.egg-info

我可以导入sklearn并且在之前打印的sys.path中找不到sklearn。

我搜索了StackOverFlow但却发现几乎在几年前提出的有关PIL或Pillow的问题,与我的情况不一样。 (我想我用pip3成功安装了Pillow ..)

我是新来的,并在寻求答案......

0 个答案:

没有答案
相关问题