Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded the Python package from the website. It is in my C drive, in a directory named Python27. In the command prompt, I type the following:

cd C:\Python27

Then I get Python 2.7.4. and the opening message. My Python file, called, is in the desktop, and I don't know how to access it. I've tried the following..

python cd Desktop\
python cd Desktop\""

What is the correct command?

share|improve this question

migrated from Oct 7 '13 at 7:58

This question came from our site for professional and enthusiast programmers.

Are you trying to change directory to the folder holding the file? (Also, if you could put the output when you attempted those commands, it would help.) – BlackVegetable Oct 6 '13 at 21:49
The Desktop directory on Windows is C:\Users\<USERNAME_HERE>\Desktop, I believe. – li.davidm Oct 6 '13 at 21:49
Did you try C:\Python27\python.exe C:\Users\username\desktop\ ? (assuming no space in the username and no c:\python in the path). – Hennes Oct 28 '14 at 21:47
Alternatively, right click on the python file on the desktop and select [always] open with this program. Then select the python binary. – Hennes Oct 28 '14 at 21:49

You have to add python to your path, then you can open a command line in the directory of your file and type:

share|improve this answer
i have already added python to my path, i think – Yuen Hsi Oct 6 '13 at 22:32
Then open up a command line, cd to your file's directory, and type the command I wrote above. – Jakob Weisblat Oct 6 '13 at 22:42
Note that you need to type this BEFORE opening python – Jakob Weisblat Oct 6 '13 at 22:45

If your program does not need the console (e.g. automation scripts or GUI programs), then double click on the script file to execute it.

Otherwise, in modern Windows (Vista, Seven, 8), you folder is located under \Users. Let's say the script is the Desktop folder of user Foo, so it would be:

python c:\Users\Foo\Desktop\
share|improve this answer
i did that; i got a syntax error: invalid syntax. command prompt thinks i'm typing code instead of trying to run a file? :( – Yuen Hsi Oct 6 '13 at 22:35
You'd have to type it in outside of python – Jakob Weisblat Oct 6 '13 at 22:43

Go like this:

  • open a console
  • > cd Desktop
  • > c:\Python27\python

Best to add C:\Python27 to the system PATH variable though.

share|improve this answer
i get can't open file '' ; no such file or directory :( – Yuen Hsi Oct 6 '13 at 22:33

You can also do this in command prompt:

start C:\Users\your_username_here\Desktop\

You can even do this in python! Here is how:

import os
os.system("start "+yourPathHere)

A very simple program would be:

import os
while True:
    userInput=str(input("Enter file/app path: "))
    os.system("start "+userInput)
    print ("") # - just for the looks -

The more you know :p

share|improve this answer

Make sure you set up the path like this by adding this in the Environmental Variables: %path% on your settings. C:\WINDOWS\system32;C:\WINDOWS;C:\Python27

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .