Command framework and PYTHONPATH


Hello All,

Starting to move to Python for my team (I’m the programming mentor). I use it (somewhat) professionally, so am fairly conversant in it. However, I’m not much of an eclipse user (doing it only for the kids), preferring emacs in
the professional world.

I installed PyDev into Eclipse, and manually created the Command framework based on - when I say manually created, I created folders manually, and added new files into these folders manually. This results in a folder structure that looks like:
> pybot
>> Commands
>> Robot
>> Subsystems

Eclipse thinks all is OK (no red flags indicating syntax problems). I’m able to do install-robotpy deploy --skip-tests to get the code transferred to the rio.

When I do install-robotpy run, I get:
File “/home/lvuser/py/”, line 7, in <module>
from Subsystems import Motor
ModuleNotFoundError: No module named ‘Subsystems’

I’m not sure what to do (if anything) with PYTHONPATH, and the doesn’t make any references to the variable. Or, is there some other configuration thing I’ve not set up properly.

I’ve also tried running this from the command line on the driverstation laptop - --help - and I get the same error. I’ve tried setting PYTHONPATH to the project directory, to no avail.

Thanks for any help on this…


Looking at the diagram you made of your file layout, appears to be in a sister directory (Robot) from Subsystems. That means that Subsystems is not in’s import path.


You can solve this one of two ways.

  1. Add the Subsystems folder to PYTHONPATH, or call sys.path.append( path ) for it inside your code.
  2. Assuming the root “pybot” folder is on your python path already, just add an empty file to the Subsystems folder, which declares it as a package containing importable modules.

#2 would by my recommendation.


As stated by others, for best results your should be at the root of your robot code source tree.


Sorry for being incommunicado for a while.

Moving the file to the same level as the commands and subsystem folders. did the trick.

Thank you all.