org-arl / arlpy

ARL Python Tools
BSD 3-Clause "New" or "Revised" License
119 stars 37 forks source link

Python 3 no longer supports implicit relative import #4

Closed ymtoo closed 6 years ago

ymtoo commented 6 years ago

In Python 3, the following error occurs when arlpy is imported:

>>> import arlpy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/arl/anaconda3/lib/python3.6/site-packages/arlpy/__init__.py", line 14, in <module> import geo ModuleNotFoundError: No module named 'geo' .

Since Python 3 does not allow implicit relative import, we can replace

import geo import uwa import utils import comms import signal

in __init__.py with

from arlpy import geo, uwa, utils, comms, signal ,

and

from signal import time as _time

in comms.py with

from arlpy.signal import time as _time .

The changes are due to the fact that absolute imports are recommended by Python developers. (https://www.python.org/dev/peps/pep-0008/#imports)