I am having issues calling a function which is in a separate file contained in the subfolder.
Directory structure is attached.
The file is msgTypesPy/cam/camHandler.py. If I run it alone, everything works as expected.
import json
import cam
def decode():
value = json.loads(r'{"............."}', parse_float=str)
try:
encoded = cam.CAM_PDU_Descriptions.CAM.encode('UPER', value)
print('Encoded HEX: ' + ', '.join(['0x{:02X}'.format(val) for val in encoded]))
print()
decoded = cam.CAM_PDU_Descriptions.CAM.decode('UPER', encoded)
print('Decoded value: {}'.format(json.dumps(decoded, default=str)))
print()
except NotImplementedError as e:
print('Not Implemented Error : {}'.format(format(e)))
decode()
If I run messageHandler.py which has the following code:
from msgTypesPy.cam import camHandler
camHandler.decode()
it fails with an error:
Traceback (most recent call last):
File "c:/Users/Srdan/Desktop/Dev_C-ITS/messageHandler copy.py", line 1, in <module>
from msgTypesPy.cam import camHandler
File "c:\Users\Srdan\Desktop\Dev_C-ITS\msgTypesPy\cam\camHandler.py", line 2, in <module>
import cam
ModuleNotFoundError: No module named 'cam'
Could you help me and explain why the module is not found when the function is called from another file?
I really do not understand what the issue here is...