首页 > 解决方案 > 尝试安装 Python PIL 模块失败并出现“非零退出代码”

问题描述

我真的不明白为什么 Python 很难正常启动和运行。

无论如何,我刚刚安装了 Python 3.7 和 PyCharm。我想让 Python Imaging Library 在我的项目中工作,但是当我尝试使用 PyCharm 安装它时,出现以下错误:

pip install PIL
Non-zero exit code (1)
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\Users\Jake\AppData\Local\Programs\Python\Python37-32\python.exe'.

Command output:
Collecting PIL

  Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

我尝试python -m pip install --upgrade pip从 CMD 提示符运行,但随后出现此错误:

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

我只是尝试使用与 PIL 和 Numpy 完全相同的方法安装 NumPy,没有任何问题。这让我认为 Python 3.7 可能不支持 PIL?

有人可以向我解释这里的问题并帮助我将模块导入我的 PyCharm 项目吗?

标签: pythonpycharm

解决方案


PIL 不再维护。您可以改用 Pillow,它是 PIL 的一个更活跃的分支。

pip install Pillow

推荐阅读