The PIL library import fails

烈酒焚心 提交于 2019-12-24 14:56:56

问题


Being a complete begginer in python, I decided to install the python interpreter 3.4.4, and also PyDev plugin for eclipse IDE. I am also using windows 10.

I have encountered a problem regarding certain imports, namely : from PIL import Image, ImageTk, which is apparently an unresolved import.

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. Here are some topics I visited :

  1. Uninstalling and reinstalling Pillow and pip,
  2. Installing pillow-imaging-tk on Ubuntu,
  3. This topic which left me very confused,
  4. This one seemed helpful, but is on Unix OS again

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.


回答1:


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,
  2. Via cmd, type pip install pillow. Alternatively, you can enter the same command from Windows+R,
  3. (Not sure if relevant step) Via eclipse, Windows->Preferences->PyDev->PythonInterpreterremove your interpreter to re-add it,
  4. Restart eclipse.



回答2:


For Python import problems in PyDev, the project web site has a page on interpreter configuration that is a good place to start. I recently had a similar problem that I solved by adding a module to the forced builtins tab.



来源:https://stackoverflow.com/questions/36900272/the-pil-library-import-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!