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

What's the best way to work with SQL Server data non-programmatically?

sql-server ms-access ssms

We have a SQL server database. To manipulate the data non-programmatically, I can use SQL Server Management Studio by right-clicking a table and selecting "Open Table". However this is slow for very

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.