1
votes

I'm running PyDev in Eclipse 4.2 on Mountain Lion. I installed the SciPy Superpack, and can use all the packages -- including Scikit-learn and MatPlotLib -- in the Python interpreter and through IPython. However, when I try to import them in PyDev I get an 'Unresolved import' error.

I installed Python 2.7.3 from Python.org, and verified that PyDev is pointing to the correct interpreter. I also attempted to add the sklearn and matplotlib directories (verified via the path from sklearn.__file__) to the System PYTHONPATH in the PyDev settings. This didn't resolve the issue.

Any idea what else I should try?

1
Did you add them to the forced builtins, in that same preference location? Also, can you post an example of the paths you added to PYTHONPATH? - jdi
Yes, I tried that too. It eliminates the initial unresolved import error, but throws it again as soon as I try to use anything the modules actually contain. 'from sklearn import datasets' is still unresolved, for example. - David M.
Example of path added to PYTHONPATH: '/Library/Python/2.7/site-packages/scikit_learn-0.12_git-py2.7-macosx-10.8-intel.egg/sklearn/' - David M.
Ya that path would be incorrect. You only need the site-packages level, and the egg level. Not inside. The way you have it now would allow: import datasets - jdi
'/Library/Python/2.7/site-packages/' is also in the PYTHONPATH. It still didn't work, even with the packages added to Forced Builtins and only the site-packages level in the PYTHONPATH. - David M.

1 Answers

1
votes

From your comment examples, seems the path you are using is at the wrong depth.

Change from:
/Library/Python/2.7/site-packages/scikit_learn-0.12_git-py2.7-macosx-10.8-intel‌​.egg/sklearn

To:
/Library/Python/2.7/site-packages/scikit_learn-0.12_git-py2.7-macosx-10.8-intel‌​.egg

It wasn't able to find the package level name because you were specifying beneath it. Normally a python interpreter will resolve all the eggs by simply existing insite the site-packages, from the `.pth' file references that get placed there. But I think pyDev will need explicit adding of those eggs to the PYTHONPATH.