当我尝试导入Image模块时,无法找到该模块。
nn-MacBook-Pro-3:~ nn$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Image
>>>
Pip列表显示已安装。
nn-MacBook-Pro-3:~ nn$ pip 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.
appnope (0.1.0)
bleach (1.5.0)
cycler (0.9.0)
dask (0.13.0)
decorator (4.0.11)
distribute (0.7.3)
Django (1.10.5)
email (6.0.0a1)
entrypoints (0.2.2)
Flask (0.10.1)
html5lib (0.9999999)
image (1.5.5)
我正在使用Mac的默认python版本。
nn-MacBook-Pro-3:~ nn$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
PYTHONPATH变量似乎是空的,但是当我尝试导入其他已安装的软件包时,它没有显示&#34;没有找到模块&#34;错误。
nn-MacBook-Pro-3:~ nn$ echo $PYTHONPATH
我也尝试过here所说的一切,但它对我没用。
更新
由于建议模块区分大小写,我尝试了以下操作,但它没有工作。
nn-MacBook-Pro-3:~ nn$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named image
答案 0 :(得分:1)
您需要import image
代替import Image
模块名称区分大小写