If you use Windows on your own computer, you can install Python and start writing your own programs pretty quickly. You shouldn't have too much trouble as you area learning, but at some point you might notice that some of the resources you'd like to use are written for Linux or Mac users. At that point you will have a number of options, and we will help you work through those issues when they come up.
Python is probably not installed on your system yet. To find out if it is installed, open a terminal and type the word python
. If you haven't used a terminal before, go to your Start menu and start typing the word 'command'. You will see an icon for the Windows command console, a black icon. Click this, and type the word 'python'. You will probably get a message that Windows does not recognize 'python' as a command.
If you do have Python installed, you can skip to the section on installing Geany.
Since you are starting out fresh, it's probably a good idea to just install the newest stable version of Python. Most people who still use Python 2 do so because they have to maintain large projects that were written for Python 2. Unless you know you will have to maintain an existing project you are probably better off learning Python 3 from the beginning.
The main Python website has a section written just for beginners who are trying to install Python. If you get stuck, take a look at that page and see if anything seems to make sense for your particular system.
Here is what has worked for me, for both Windows 7 and Windows 8:
Once Python has finished installing, you want to make sure it is working. There are several ways to do this.
print("Hello Python world!")
, and press Enter.C:\Python32\python
, and press Enterprint("Hello Python world!")
, and press Enter.If you want to start out on Python 2, the instructions are almost identical to installing Python 3. Follow the instructions above, but when you get to the step for choosing an installer, look for the "Python 2.7.3 for Windows" link.
When you try to open a terminal window and run Python, your path will probably be C:\Python27\python
.
Hello Python world!
------------------
(program exited with code: 0)
Press return to continue
You will probably see an error message, because Geany doesn't know where Python lives on your system. We will fix that in the next section.
You probably have to configure Geany to tell it how to find the version of Python that you just installed.
Open Geany, and open a Python Hello World program. If you don't have one on your system, write one and save it as hello.py, and run the program. This makes sure that Geany is trying to run Python programs. When you have a running hello.py program, go to Build >> Set Build Commands.
Under 'Python commands', look for the 'Compile' line. Enter the following in the 'Command' box. Make sure you get the spaces right. You should have 'C:\Python32\python' followed by a space, and the rest of the command. If you have 'Python 32', with a space between Python and 32, Geany will not be able to run your code. Also, make sure your capitalization matches what you see here exactly.
C:\Python32\python -m py_compile "%f"
Under 'Execute commands', look for the 'Execute' line. Enter the following in the 'Command' box, paying attention once again to the spaces.
C:\Python32\python "%f"
Test your setup by running hello.py again.
If you installed Python 2 instead of Python 3, the commands you want are probably:
C:\Python27\python -m py_compile "%f"
and
C:\Python27\python "%f"
If Geany still cannot run your hello.py program, check to see if your installation of Python is somewhere else.
C:\Python
xxx\python
.If you have run into any difficulty configuring your Windows system to run Python, you may want to consider running Linux on your system. You can do this without affecting your Windows installation, if you are careful.
The best ways to do this are:
Some bad ways to do this are:
That said, you shouldn't be scared at all about Linux. Linux has gotten pretty user-friendly, and once you have it installed it will behave like most other modern operating systems.
You can install something like VirtualBox or VMWare, and install Linux within your current Windows installation. To run Linux under this configuration, you would:
In this scenario, you are letting Windows manage the Linux computer.
Specific instructions for this will be added shortly.
In this configuration, you load Linux as a separate operating system on your computer. To run Linux under this configuration, you would:
In this scenario, neither system is really aware of the other. Your computer only knows, when you turn it on, that there are two separate operating systems available to you.
Specific instructions for this will be added shortly.