NameError: name 'Session' is not defined


Python 3.12.0 gives this error if code is run from IDLE.
If I run this from command line it works.
Same error with Pythons 3.9.5 and 3.10.0

Error printout:

(Traceback (most recent call last):
  File "C:\WORK_PYTHON\scamp\", line 1, in <module>
    from scamp import *
  File "C:\WORK_PYTHON\scamp\", line 3, in <module>
    s = Session()
NameError: name 'Session' is not defined)

The full code that resulted in the error:

(from scamp import *

s = Session()

cello = s.new_part("cello")
cello.play_note(48, 1.0, 1.0))

Hi Eranh0 - are the parentheses that enclose the snippet in your actual code? Removing them works for me. That wouldn’t explain why the code works in other contexts though

Hi chris,
No those brackets are not in the code. Just messed up the message

I just noticed: you called the file That might be confusing the import mechanism. Try calling the file something else, and make sure there’s no file floating around called

You were right! I was idiot enough to name my test code :man_facepalming:


1 Like

Happens to the best of us!

1 Like