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
.py=Python.File
>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 django-admin.py 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!

Answers


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

C:\Python27\Python.exe

Need Your Help

backbone js MVC semantics advice

javascript jquery model-view-controller backbone.js

I'm building my first site based on backbone.js and I have a bit of a semantics question.

What am I missing? RestSharp won't deserialize Json

c# json foursquare restsharp

I am trying to turn a json response back from foursquare into objects. I get something like this back

Adding a variable to a dataset if it doesn't exist

r variables

Working in R, I need to add a column of zeros for missing days - if there are any.

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.