Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Instant Objects Let's Make a Class!

Matthias Binder
Matthias Binder
3,724 Points

Import Error : cannot import name 'Thief'

Hello TreeHouse Students,

im asking myself why i cant import The Thief class. Normally im using Sublime to follow along the tasks but since ive got no idea how to import an class in sublime changed to Workspace. But i keep getting the import Error. I would be glad if someone could tell me what im doing wrong and how i can import an class in sublime. Thanks

code i wrote: class Thief: pass

then in the workspace console: run python then: from characters import Thief

3 Answers

Steven Parker
Steven Parker
231,275 Points

Two things come to mind to check:

  • is the code in a file named "characters.py"?
  • did you remember to save using the key shortcut or the menu?

if that's not it, you can make a snapshot of your workspace and post the link to it here.

Matthias Binder
Matthias Binder
3,724 Points

Oh yes youre right. I forgot to save the file. thanks alot.

I am having this error frequently, too. I have switched to running python3 in my console using Visual Studio Code, and I don't get any errors at all. I think part of the problem is the Treehouse Workspace