If you have import statement like this: import gdata.spreadsheet.service
then you need to make sure that on PYTHONPATH
there is a directory that contains gdata
subdirectory (and gdata
should have spreadsheet
subdirectory with service.py
module file).
In your case: if your gdata
directory is in site-packages
directory on python distribution, then you need to make sure that site-packages
is on PYTHONPATH (not site-packages/gdata/spreadsheet
that you were trying to put there).
Look at http://docs.python.org/2/tutorial/modules.html in "6.4 Packages" section for example and reference.
In PyDev you can modify the contents of PYTHONPATH in two places:
- Window -> PyDev -> Interpreter - Python
- In the window you used
I would suggest you to first check that site-packages
directory is in your Window -> PyDev -> Interpreter - Python settings -> System PYTHONPATH
. It should be there by default, so if you didn't change it, it should be present there (and probably that's why your application works!).
Now, from some reasons, PyDev often has problems with "refreshing" info about available libraries after adding a new library to site-packages
(and it uses that info for example to check if it should put error marker on import statement).
There are a few ways to force the refresh of this info. The most reliable for me is just removing python interpreter by means of: Window -> PyDev -> Interpreter - Python -> Remove
and then adding it back in the same view. Then the site-packages
directory is rescanned and PyDev sees the updated set of libraries, so the error markers should disappear.
Side note: To be honest, so far I haven't ever need to use this External Libraries
view. Having site-packages in Interpreter settings is fine enought for 99% of cases because there is where Python external libraries should be put.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…