Question

I've nearly everything I can find to resolve these Unresolved imports. Here is what I am trying to import:

from sklearn.ensemble import RandomForestClassifier
from numpy import genfromtxt, savetxt

In eclipse on Mac OS X Lion running PyDev I get the following errors;

Description Resource    Path    Location    Type
Unresolved import: genfromtxt   makeSubmission.py   /BioResponse/src    line 1  PyDev Problem
Unresolved import: RandomForestClassifier   makeSubmission.py   /BioResponse/src    line 0  PyDev Problem
Unresolved import: savetxt  makeSubmission.py   /BioResponse/src    line 1  PyDev Problem

Note this is for setting up Kaggle.

The thing I dont get is that when I am in terminal and type the following commands, everything seems ok (I don't see any visible errors):

$python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import savetxt
>>> 

Please try to explain in detailed steps if you know a possible solution. I'm new to Macs and PyDev

Was it helpful?

Solution

Maybe you have 2 python interpreters installed on your system and the one used by PyDev is not the one where numpy is installed.

Type which python in a terminal to know the path of the python installed in your PATH where numpy is installed and then go to the PyDev preference menu to know which python is configured for PyDev.

OTHER TIPS

Another solution could be to add your /Library/Python/2.x/site-packages folder to System Libs in the Eclipse Preferences under 'PyDev -> Interpreter Python -> Libraries'.

Based on David's solution be sure the proper typing. For me (in Eclipse): Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter -> (Chose the version on the top) -> Libraries -> And here there was a typo:

C:\Python35\lib\site-packages

instead of

C:\Python35\Lib\site-packages

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top