Search code examples
eclipsepydevsix

Why does PyDev Eclipse editor reports errors in the code that do not exist?


My PyDev Eclipse project has only one file with these four lines:

import os
from six.moves.urllib.request import urlretrieve
from six.moves import cPickle as pickle
print("OK")

Eclipse reports these "Problems":

Unresolved import: pickle   main.py /1_notminst line 2  PyDev Problem
Unresolved import: urlretrieve  main.py /1_notminst line 1  PyDev Problem

However, Eclipse runs the program without any issue, and prints "OK", as well as python3 (or ipython3) from command line:

> python3 main.py
OK

Any idea why the editor of Eclipse+PyDev doesn't see that library? It is the Python Six library. pip3 reports the library is installed:

> pip3 show six
---
Metadata-Version: 1.1
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/lib/python3/dist-packages
Requires: 
Classifiers:
  Programming Language :: Python :: 2
  Programming Language :: Python :: 3
  Intended Audience :: Developers
  License :: OSI Approved :: MIT License
  Topic :: Software Development :: Libraries
  Topic :: Utilities

Import of other libraries are just fine.

I am running Eclipse Mars under Ubuntu 16.04 and Python 3.5.

Thanks!


Solution

  • I found out how to resolve this, thanks to others who posted on stackoverflow. The short of it, add "six" to the project properties under PyDev - Interpreter/Grammar > Click here to configure and interpreter not listed > Forced Builtins > New ...

    Eclipse took several minutes to process the change, eventually it worked.

    Here the posts that helped: Eclipse-Pydev cannot find Lucene Library