Steve
Steve

Reputation: 2816

Eclipse PyDev : __module_not_in_the_pythonpath__

CentOS Linux release 7.6.1810 (Core)

openjdk 11 2018-09-25

Python 3.6.9

Eclipse IDE for RCP and RAP Developers Version: 2019-06 (4.12.0)

PyDev 7.0.3.2018.11082356

I'm new to PyDev and pretty new to Python.

I have a Python project composed of several dozen Eclipse projects/plugins.

When I hover a Python method in our code to get more information or use tools on it I get this error message:

Found at: __module_not_in_the_pythonpath__

enter image description here

Each Eclipse project was imported this way:

Import > Git > Projects From Git > Existing Local Repository > Select A Repository ( choosing all the projects in the repo, then moving on to "finish": )

Each Eclipse project has:

  1. "src" directory containing *.java files
  2. "util" directory containing *.py files
  3. an autogenerated .project file ( underpopulated )
  4. an autogenerated .pydevprodject file ( underpopulated )

enter image description here

The .project file I have:

enter image description here

The .pydevproject file I have:

enter image description here

Obviously, from this FAQ those .project and .pydevproject files need to be updated.

The "util" dir is the parent directory for all of the projects *.py files. It does not have an __init__.py file. Do I need to put one in the "util" dir to fix this error? Will a single __init__.py file in the "util" dir will that be enough for Python and Eclipse to find all of the *.py files in the subdirectories beneath it?

Upvotes: 2

Views: 818

Answers (1)

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

I'm not sure if the module wasn't really imported as a PyDev project (because the project root was not shown in the screenshot).

If that's the case, you can convert your project to a PyDev project by right-clicking it and choosing PyDev > Set as PyDev project.

After having it as a PyDev project you have to set each folder that's in the PYTHONPATH as a source folder (note that just the entry in the PYTHONPATH must be set this way, not subfolders).

You can either right-click the folder and choose PyDev > Set as source folder or if you have too many entries you can create a script to generate your .pydevproject files with those entries as explained in http://www.pydev.org/faq.html#ImportExistingSources.

Note that you should not add those folders to the interpreter PYTHONPATH (the folders added to the PYTHONPATH in the interpreter are shared across all projects, whereas the folders added as source folders are valid only for one project -- if you have multiple projects PyDev will compose the final PYTHONPATH based on the interpreter + project + referenced projects).

Upvotes: 1

Related Questions