Shwetanka
Shwetanka

Reputation: 5036

.py files opens up in a text editor when run from cmd

Whenever I try to run a .py file from cmd it opens up in a text editor(np++). I'm trying to run the following:

django-admin.py startproject testprj

Even if I run 'setup.py install'

Upvotes: 5

Views: 10902

Answers (3)

user225312
user225312

Reputation: 131677

You need to change the file association so that .py files open with Python executable, typically located in C:\Python<version>\ and not Notepad++

Changing this should be easy, but here is how to do it.

Also, read here on to set the environment path so that the Python executable is found without you having to navigate to C:\Python2.6.

Upvotes: 4

Szpaqn
Szpaqn

Reputation: 595

To extend the answers. After changing the default exec to open .py files, you might need to change scripts are opened, so that all the command line arguments are passed to the script. You can do it using Registry Editor (regedit).

  1. Open Start Menu and type: regedit

  2. In the editor go to:

    Computer\HKEY_CLASSES_ROOT\Applications\py.exe\shell\open\command

  3. modify the value to be equal to: C:\Windows\py.exe "%1" %*

Upvotes: 0

wkl
wkl

Reputation: 79921

Your Windows file associations are set to open .py files in a text editor. You have to change those to use the python.exe interpreter, or you can prefix all your commands with python, like this:

python django-admin.py startproject testprj

If you want to change your file associations, and you are running Vista or Windows 7, you can change them in 'Control Panel'->'Default Programs'->'Associate a file type or protocol with a program'

Upvotes: 1

Related Questions