0

I am using 1) Vi Improved 7.4 & 2) Syntastic syntax-checker for vim.

When I tried to import the "sklearn.metrics" module to use the "pairwise_distances" functions,
from sklearn.metrics import pairwise_distances works in both the 'python' & 'python3' terminal mode.

However, the same line caused: foo.py|8 col 1 error| [import-error] Unable to import 'sklearn.metrics' when I put it in a .py file and opened with vim foo.py. Yet executing the file with python3 foo.py did not report any error.

I also tried another way to import the module by doing import sklearn.metrics as sk_met and call sk_met.pairwise_distances(...) in the body of my code. This works for all the aforementioned methods ('python', 'python3', 'vim foo.py'). It seem to me vim can find "sklearn.metrics" just fine, but not through from ... import.

Could it be the syntax checker's problem?

enter image description here

Sean
  • 713
  • 1
  • 10
  • 28
  • 3
    Syntastic is just a framework, it doesn't know, nor cares, about the contents of your files. Find out which _checker_ complains about your code. Also, read the [FAQ entry](https://github.com/vim-syntastic/syntastic#faqpython) about using syntastic to check both Python 2 and Python 3 code. – lcd047 Dec 16 '16 at 05:40
  • But shouldn't "import ... as ..." behave the same way "from ... import ..." do in terms of whether a module exists and can be imported? – Sean Dec 16 '16 at 06:40
  • 1
    Err, find out which _checker_ complains about your code? – lcd047 Dec 16 '16 at 07:57

0 Answers0