I'm having a problem with some (likely badly-written) Python2 code, which I'm trying to convert to Python3. I'm sure this has been answered somewhere else before, but my Google-fu is not up to this task. I'm developing this on Ubuntu 18. (I know, Python2 and Ubuntu 18 are way way EOL, but my company is very slow to do the upgrade thing)
All of my code lives in the $HOME/python directory. I've added $HOME/python to my PYTHONPATH environment variable. My script is in $HOME/python/scripts, and is simply:
import modules.foo
In the $HOME/python/modules directory, I have an (empty) __init__.py, and modules bar.py and baz.py:
bar.py:
import baz
bar = 0
baz:py
baz = 0
This works fine when I execute with Python2. However, when I attempt to execute using Python3, I get:
Traceback (most recent call last):
File "scripts/foo.py", line 1, in <module>
import modules.bar
File "/home/kplatz/python/modules/bar.py", line 1, in <module>
import baz
ModuleNotFoundError: No module named 'baz'
How do I resolve this (without breaking Python2 compatibility, if possible)?
Thank you in advance!