【问题标题】:Python Module not found error even when the module is installed即使安装了模块,Python Module not found 错误
【发布时间】:2017-07-10 15:15:19
【问题描述】:

当我尝试导入 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 变量似乎为空,但是当我尝试导入其他已安装的包时,它没有显示“未找到模块”错误。

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

【问题讨论】:

    标签: python macos python-module


    【解决方案1】:

    您需要使用import image 而不是import 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. &gt;&gt;&gt; import image Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: No module named image
    猜你喜欢
    • 2022-08-18
    • 2019-06-09
    • 2016-07-04
    • 2022-10-22
    • 2021-06-01
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多