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

Help with locally installed python

I just installed Python locally, but have several questions.

How do I create files of projects and save them like in the workspaces?

I still do not quite understand the whole virtualenv thing either...How exactly does it work and what exactly does it do? I am completely new to coding and all this code jargon can be very difficult to follow.

Could someone please give me a general breakdown in the process of using python locally from starting a project, saving it, editing, to running it?

I am using Windows 8 by the way.

Thanks.

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Creating the files, editing them and saving them all comes down to the text editor/IDE that you're using. It has nothing to do with Python.

As for running them, you should be able to do python <filename.py> in your cmd.exe prompt just like you do on Workspaces.

Until you get to the point of installing third-party packages, or writing several different projects that need different versions of the same third-party packages, don't worry about virtualenv.

If you're running python from the desktop, rather than from the cmd.exe using the python shell, then here's some other options on how to do the things you're trying to do:

The window that opened up when you clicked on the icon is the shell window for IDLE, the built in python IDE, it will have some text at the type that say something like:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 
Type "copyright", "credits" or "license()" for more information.

or

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 
Type "copyright", "credits" or "license()" for more information.

or

Python 2.7.3 | 64-bit | (default, Aug  8 2013, 05:30:12) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

and that will be followed by : >>>

this is where you can type in things on the fly, and it's really how python is want to be used for applications such as data science where you're going to want to call files and do some scripting on the fly, and generate pretty graphics that bash or command aren't going to be friendly with.

To make a new file, you simply click on file > new window. This will open a file editing window here you can define functions, classes, constants, call you included files, and all that good stuff. Once you've got a file you've got to a place you want, you can go ahead and either do file > save there or run > run module (you can also do f5 to run the module). If the file hasn't been saved, it will require you to save it before it runs it.

When it comes to installing things like 3rd party packages, you can, to some extent, look at other development environs to let you skip out on learning how to do it on the terminal (Enthough's Canopy, for example, has a built in GUI based package handler and updater for these things), but really, at that point, if you don't feel comfortable with at least a little command line work, you might want to take a course on it, there's a console basics course here on treehouse that I think is pretty good for that.