Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
I'm stuck. It seems like I get a 'Name Error' no matter what I do now.
Is there a way to get a fresh start on this Workspace? I'm not sure if I jacked the files up or something of that nature. But it seems like no matter what I try to do in the console results in a Name Error every single time. Not very adept at reading errors (yet). But to me, it almost seems as if it's no longer finding the files from the module when I try to run them.
Here's some of what I entered to show an example:
Python 3.9.0 (default, Jan 21 2021, 00:46:14) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> hello.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'hello' is not defined >>> hello.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'hello' is not defined >>> hello.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'hello' is not defined >>> goodbye.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'goodbye' is not defined >>> welcome.md Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'welcome' is not defined
Please help me out if you know what I'm doing wrong; or if there's a way I can fix it. I'm eager to learn and progress on this track. But can't and don't want to do so until I get this sorted out.
AJ TranTreehouse Teacher
Hi Scott Pileggi !
So in the workspace it looks like you were working in the Terminal and entered the Python Interpreter. You will know you're in "Python-land" because of the three angled brackets,
>>>. You can exit the interpreter with the keyboard shortcut
<control> + d or by sending the command,
In the interpreter, you can import your code as Chris Freeman did demonstrate with some code snippets. This is nice if you want to "interactively" explore your program.
But for most beginners, it is more common to run your program from the command line. In your terminal, when you see the words,
treehouse:~/workspace$, it means you are back on the command line. From here, you can run your script with
python hello.py and you have to send that command all on one line. Then, if your program has
You can totally play around and manage your workspaces too! Visit the Workspaces page to do so -- there is also a tutorial video there.
Hope this helps you, Scott! Be safe and happy coding!
Chris FreemanTreehouse Moderator 67,623 Points
The REPL interpreter only sees the built-in core python code by default. To access other modules they must be imported.
>>> import hello >>> hello.some_function() # or >>> from hello import some_function >>> some_function()
Post back if you need more help. Good luck!!!
Great! I figured it out! typing 'python hello.py' solved my problem. I'm brand new to this so I'm still getting familiar with what does what, what to type where, all of it really!
I'm just happy this was easily cleared up. I've been eager to keep moving forward! Hoping to be fluent in python in no time!