如何在Eclipse中将PIL添加到PyDev,所以我可以导入它并在我的项目中使用它?

时间:2021-11-23 10:56:57

I am trying to work with PIL in my project but the pydev can't seem to find it in my project. First of all I can see it when I enter the python shell, I can import it and I see it in the python sys.path. Second, I Added it to the PYTHONPATH in eclipse.

我正在尝试在我的项目中使用PIL,但pydev似乎无法在我的项目中找到它。首先,当我进入python shell时,我可以看到它,我可以导入它,我在python sys.path中看到它。其次,我把它添加到日食中的PYTHONPATH。

I restarted eclipse, but still, when I try to do "from PIL import Image" I am getting: "unresolved import".

我重新启动了eclipse,但是,当我尝试“从PIL导入图像”时,我得到:“未解决的导入”。

Can any one please help me here, all other packages I used until now worked great the same way.... and i really need to use PIL

任何人都可以在这帮助我,我使用的所有其他包直到现在以相同的方式工作....我真的需要使用PIL

2 个解决方案

#1


9  

Had the same problem here. Got it resolved by adding /usr/share/pyshared to the Libraries tab in window->preferences->pydev->Interpreter - Python.

这里有同样的问题。通过将/ usr / share / pyshared添加到window-> preferences-> pydev-> Interpreter - Python中的Libraries选项卡来解决问题。

There were a lot of /usr/lib/python* paths with the compiled libraries (the C stuff with python bindings) where included already, but not /usr/share... parts with the source.

有很多/ usr / lib / python *路径与已编译的库(带有python绑定的C东西)已包含在内,但不包含/ usr / share ...与源代码的部分。

#2


10  

Try to go to Window -> Preferences -> Pydev-> Interpreter -> Python Interpreter -> Forced Builtins tab. Then add a PIL entry and apply. I've had the same unresolved import error when tried to import from this particular package (other packages worked fine), and found this information which finally helped me.

尝试转到Window - > Preferences - > Pydev-> Interpreter - > Python Interpreter - > Forced Builtins选项卡。然后添加PIL条目并应用。尝试从这个特定的包导入时,我有同样未解决的导入错误(其他包工作正常),并发现这些信息最终帮助了我。

#1


9  

Had the same problem here. Got it resolved by adding /usr/share/pyshared to the Libraries tab in window->preferences->pydev->Interpreter - Python.

这里有同样的问题。通过将/ usr / share / pyshared添加到window-> preferences-> pydev-> Interpreter - Python中的Libraries选项卡来解决问题。

There were a lot of /usr/lib/python* paths with the compiled libraries (the C stuff with python bindings) where included already, but not /usr/share... parts with the source.

有很多/ usr / lib / python *路径与已编译的库(带有python绑定的C东西)已包含在内,但不包含/ usr / share ...与源代码的部分。

#2


10  

Try to go to Window -> Preferences -> Pydev-> Interpreter -> Python Interpreter -> Forced Builtins tab. Then add a PIL entry and apply. I've had the same unresolved import error when tried to import from this particular package (other packages worked fine), and found this information which finally helped me.

尝试转到Window - > Preferences - > Pydev-> Interpreter - > Python Interpreter - > Forced Builtins选项卡。然后添加PIL条目并应用。尝试从这个特定的包导入时,我有同样未解决的导入错误(其他包工作正常),并发现这些信息最终帮助了我。