Apr-30-2020, 12:15 AM
Hello,
I am fairly new to python and I am receiving following error while executing the below python code in IDLE.
Appreciate your help.
Thanks
Arjun Pi
I am fairly new to python and I am receiving following error while executing the below python code in IDLE.
Error:Traceback (most recent call last):
File "/SunFounder_PiCar-S/example/test_ultrasonic_module.py", line 1, in <module>
from SunFounder_Ultrasonic_Avoidance import Ultrasonic_Avoidance
ImportError: cannot import name 'Ultrasonic_Avoidance' from 'SunFounder_Ultrasonic_Avoidance' (unknown location)
*****************from SunFounder_Ultrasonic_Avoidance import Ultrasonic_Avoidance import time UA = Ultrasonic_Avoidance.Ultrasonic_Avoidance(20) threshold = 10 def main(): distance = UA.get_distance() status = UA.less_than(threshold) if distance != -1: print('distance', distance, 'cm') time.sleep(0.2) else: print(False) if status == 1: print("Less than %d" % threshold) elif status == 0: print("Over %d" % threshold) else: print("Read distance error.") if __name__=='__main__': while True: main()*****************


Appreciate your help.
Thanks
Arjun Pi