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
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 1,058 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 3,573 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'get_config' russray2008 0 4,761 Sep-20-2021, 02:18 PM
Last Post: russray2008
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 10,442 Oct-09-2020, 06:58 AM
Last Post: ciuffoly
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,945 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10) spiffspaceman 4 2,696 May-22-2020, 10:16 PM
Last Post: snippsat
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,911 Dec-11-2019, 07:50 AM
Last Post: parsley
  import error (unknown location) pseudo 1 10,787 Nov-14-2019, 11:47 PM
Last Post: pseudo
  getting ImportError: cannot import name 'HAProxyServer' deepakkr3110 0 1,650 Nov-12-2019, 07:48 AM
Last Post: deepakkr3110
  ImportError: cannot import name 'gui' from 'appJar' CabbageMan 1 2,824 Sep-04-2019, 07:31 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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