Windows opens .py file with C:\Python27\Python.exe despite rebinding Python.File

I followed Python's official FAQ to make .py file executable, i.e. adding .py to $PATHEXT and bind Python.File to "C:\Python27\Python.exe" "%1" %*. The result was fine:

>assoc .py
>ftype Python.File
Python.File="C:\Python27\Python.exe" "%1" %*

I recently installed virtualenv and hope to run a django project in a virtual environment called env1. The path to env1 is: "D:\env1". when I entered env1 in cmd, and try to execute directly, an ImportError Exception is thrown. I figured this is because windows invoked my default python interpreter(c:\Python27\python.exe) under which django is not installed. So I tried the following:

ftype Python.File="D:\env1\Scripts\python.exe" "%1" %*

The command executed successfully. However, the behaviour of executing .py file didn't change at all. Either double clicking the file or executing it directly by filename in cmd, c:\python27\python.exe was always invoked, as was shown from Task Manager.

At this point I can only think of that this problem is related to some windows settings and has nothing to do with virtualenv. Please help to get the binding work properly, Thanks!


Another key is overriding the key set by ftype. You can search for the key using Registry Editor also known as regedit. Search for


Need Your Help

rails tutorial 10.3.3 feed_item failing test

ruby-on-rails rspec

I get down to 10.43 without errors, however the following errors occurred after attempting to create a micropost. The tutorial says this would happen and that I would need to go and enter a blank a...

sprintf in C#?

c# string printf

Is there something similar to sprintf() in C#?

Dropdown box filtering

c# drop-down-menu

I am creating a ASP.NET application using C# and what I want to do is create a filter. For instance, I have 2 drop down boxes