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
Beth Singley
3,491 Pointssublime text and python and workspaces ... trying to run local.
Hi, I'm really interested in being able to run the course code on my local machine because... that's what real developers do.
Taking the simple program of docstring.py and doing a straight copy/paste into Sublime text, I then hit Show Console. This is where I hit a snag. Everything shown in the workspaces is handled through interacting in the console there. However, when I load it into Sublime text and try to interact with the code via the console, I get Traceback errors.
Ex. to start every workspace interaction, you type "python". When I type that in Sublime text's console, I get "Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'python' is not defined"
EX. When I assume that this step isn't necessary and just type in the name of the file "docstring.py", I get Traceback error like this ">>> import docstring.py Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named 'docstring'"
What am I doing wrong? And why oh why did you decide to remove the Treehouse module on setting up your own environment on your local machine???
2 Answers
Jennifer Nordell
Treehouse TeacherMy first guess is that you don't have python correctly installed. But to be fair, I'm not entirely sure. But here comes the good news! They didn't remove the modules on setting up python, you just have to do a bit of digging (which I did for you).
Windows setup:
https://teamtreehouse.com/library/setting-up-a-local-python-environment-windows
Mac setup:
https://teamtreehouse.com/library/setting-up-a-local-python-environment-mac
Good luck!
Beth Singley
3,491 PointsThank you!
I think now I have figured out what's wrong (ish). Mostly I was assuming that the console in Sublime Text acted the same way as the terminal. As in, I could run commands in the console in Sublime text and get the same results as running it in the terminal.
However, I am still struggling. in the terminal, how do I direct to a particular folder location? ie. I want to import "docstring.py" but the terminal doesn't know where docstring.py actually is located. What is the right syntax for finding the file in the users folder?
Jennifer Nordell
Treehouse TeacherBeth Singley That's going to depend a bit on if it's on a separate hard drive, where it's located, and what OS you're using. Also I have no idea what your current working directory is
But let's start with OS first. Which OS are you using?
I'm guessing OS X, but I just want to verify :)
Beth Singley
3,491 PointsJennifer- I can't figure out how to comment on your last question so here goes. Yes - Mac OSX
file path is this: /Users/elizabethramsey/Development/Python/docstring/docstring.py
does that help?
Jennifer Nordell
Treehouse TeacherIt does a bit! And what is your current working directory?
Jennifer Nordell
Treehouse TeacherYou know what? Scratch that. If you want to learn how to run python on your local machine and navigate files and directories like a pro. Then you should really pause what you're doing and take a look at this course here on Treehouse. It's absolutely brilliant!
https://teamtreehouse.com/library/console-foundations
Sure, it may be a slight detour. But it may very well be the most valuable course I've ever taken on doing command line things. Period.
Beth Singley
3,491 PointsThanks Jennifer! I'll check it out.
Beth Singley
3,491 PointsJennifer - haven't checked out the video yet but figured out how to change working directories to make the files run from the terminal. Feeling empowered there. (Bwahaha!)
Next head scratcher - when working with the flask basics "simple_app.py" in treehouse, the workspack automatically opens a webpage tab to show the results of the app. (line of code is = app.run(debug = True, port = 8000, host = '0.0.0.0'))
However, I can make the app run from the terminal but I can't find where (if) the results of the app are displaying on a webpage. help?
Jennifer Nordell
Treehouse TeacherBeth Singley Oh wow! Now that's a great question! And now you're a little out of my league here. As I understand it, you're going to need some sort of webserver installed on your machine that can handle http requests. That's about all I can tell you.
Beth Singley
3,491 PointsFigured it out (with help)
open a webpage and type "localhost:8000"
That does it!
Cheers!
Beth Singley
3,491 PointsThanks you!!! Going now back to the video to see if I can remedy the issue.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBeth Singley Ok nevermind. I just looked up Flask LOL. Have never touched it. It is a web server. Good to know! Out of curiosity... what happens if you open your web browser and type this?
http://127.0.0.1:8000
I'm really curious to know if this works :)