简体   繁体   English

PIL 库导入失败

[英]The PIL library import fails

Being a complete begginer in python, I decided to install the python interpreter 3.4.4, and also PyDev plugin for eclipse IDE.作为一个完整的python初学者,我决定安装python解释器3.4.4,以及eclipse IDE的PyDev插件。 I am also using windows 10.我也在使用 Windows 10。

I have encountered a problem regarding certain imports, namely : from PIL import Image, ImageTk , which is apparently an unresolved import.我遇到了有关某些导入的问题,即: from PIL import Image, ImageTk ,这显然是未解决的导入。

I have looked at certain questions which were similar to my situation, but most of them gave a solution like installing packaged from the linux apt-get.我查看了某些与我的情况类似的问题,但其中大多数都给出了解决方案,例如从 linux apt-get 安装打包。 Here are some topics I visited :以下是我访问过的一些主题:

  1. Uninstalling and reinstalling Pillow and pip, 卸载并重新安装 Pillow 和 pip,
  2. Installing pillow-imaging-tk on Ubuntu, 在 Ubuntu 上安装 Pillow-imaging-tk,
  3. This topic which left me very confused, 这个让我很困惑的话题,
  4. This one seemed helpful, but is on Unix OS again 这个看起来很有帮助,但又是在 Unix OS 上

So please, could someone explain to me why I am seeing this error, and how could I correct it if I absolutely want to use Eclipse, Pydev, windows 10 and Python 3.所以请有人向我解释为什么我会看到这个错误,如果我绝对想使用 Eclipse、Pydev、Windows 10 和 Python 3,我该如何纠正它。

Found the solution, here's what I did:找到了解决方案,这是我所做的:

  1. Set the PYTHONPATH like it is shown in this article , make sure python.exe is accessible via cmd,按照本文所示设置 PYTHONPATH,确保可以通过 cmd 访问 python.exe,
  2. Via cmd, type pip install pillow .通过 cmd,输入pip install pillow Alternatively, you can enter the same command from Windows+R,或者,您可以从 Windows+R 输入相同的命令,
  3. (Not sure if relevant step) Via eclipse, Windows->Preferences->PyDev->PythonInterpreter remove your interpreter to re-add it, (不确定是否相关步骤)通过 Eclipse, Windows->Preferences->PyDev->PythonInterpreter删除您的解释器以重新添加它,
  4. Restart eclipse.重启日食。

For Python import problems in PyDev, the project web site has a page on interpreter configuration that is a good place to start.对于 PyDev 中的 Python 导入问题,项目网站有一个关于解释器配置的页面,这是一个很好的起点。 I recently had a similar problem that I solved by adding a module to the forced builtins tab.我最近遇到了一个类似的问题,我通过向强制内置选项卡添加一个模块来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM