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 trialJake Nisenboim
3,374 PointsHow to run Python offline
I am on Ubuntu, I have bpython installed. If I make a file called hello.py How / where can I go to run the file?
jacobproffer
24,604 PointsDo you know how to change directories?
Jake Nisenboim
3,374 PointsNo I don't, any idea how to do that ? Thanks !
jacobproffer
24,604 PointsI'd recommend taking at look at this Console Foundations video. Jim explains how to move around the file system, which you'll need to know in order to navigate to your Python file.
If you're unable to view the video, please let me know and I'll try explaining the process.
Jake Nisenboim
3,374 PointsAwesome thanks! Helps alot. I ended up haing the cd correct, but I was typing in cd python/ instead of cd Python/ .
In any case the program doesn't seem to be working properly. The terminal response to my input is:
Traceback (most recent call last): File "lumberjack.py", line 1, in <module> name = input("What's your name? ") File "<string>", line 1, in <module> NameError: name 'j' is not defined
my code is
name = input("What's your name? ")
if name == "Jake":
print("{} is a lumberjack and he is OK!".format(name))
else:
print(" {} sleeps all day and {} works all day!".format(name, name))
jacobproffer
24,604 PointsHey Jake,
Did some snooping around. According to this thread, this is a Python 2 issue.
Change your code to reflect this and it should work:
name = raw_input("What's your name? ")
If you also have the latest version of Python installed, type python3 hello.py into Terminal instead and input() should work at intended.
1 Answer
jacobproffer
24,604 PointsHey Jake,
Do you know how to open the terminal on Ubuntu?
Jake Nisenboim
3,374 PointsYes, but "python hello.py" brings me: python: can't open file 'hello.py': [Errno 2] No such file or directory
jacobproffer
24,604 PointsIf you're in the working directory of the file hello.py in Terminal, then type 'python hello.py' and hit enter.
Jake Nisenboim
3,374 PointsJake Nisenboim
3,374 PointsI don't understand..? I used the command "python hello.py" and the response was: python: can't open file 'hello.py': [Errno 2] No such file or directory