Python Forum
ImportError: cannot import name 'X ' from ' Y' (Unknown location)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'X ' from ' Y' (Unknown location)
#1
Hello,

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()
*****************
Wall Wall


Appreciate your help.

Thanks
Arjun Pi
Reply
#2
where did you get package SunFounder_Ultrasonic_Avoidance?
it's not in pypi
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api' AgileAVS 0 1,843 Jul-15-2024, 08:45 AM
Last Post: AgileAVS
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 2,296 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  Unknown Expression Led_Zeppelin 5 3,248 Oct-15-2022, 12:14 PM
Last Post: deanhystad
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 5,467 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'get_config' russray2008 0 5,940 Sep-20-2021, 02:18 PM
Last Post: russray2008
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 13,592 Oct-09-2020, 06:58 AM
Last Post: ciuffoly
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 5,181 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10) spiffspaceman 4 3,701 May-22-2020, 10:16 PM
Last Post: snippsat
  Help!Unknown ERROR bwdu 1 2,672 Apr-20-2020, 02:09 PM
Last Post: deanhystad
  Unknown error TheIDarKIKnight 0 2,052 Apr-19-2020, 05:27 PM
Last Post: TheIDarKIKnight

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020