开发者

python versions on winXP

开发者 https://www.devze.com 2023-01-24 03:55 出处:网络
I asked this question on superuser, and got the tumbleweed badge for it (13 views in 10 days), so I figured here might be the right place.

I asked this question on superuser, and got the tumbleweed badge for it (13 views in 10 days), so I figured here might be the right place.

There are several versions of python installed in my windows machine. I want to be able to switch easily between the versions being used as default.

I experimented and used winexplorer to change the program associated to py files. I set the program to be used to open these files as wordpad. Now when I type a .py's filename in the command line, the file opens in wordpad.

In spite of this, typing the following in the command line yields:

C:\>assoc .py
.py=Python.File

C:\>ftype Python.File
Python.File="C:\Program\Python27\python.exe" "%1" %*

I don't understand why the command line runs wordpad (as set in windows explorer), although assoc and ftype say it should run Python27.

Are these associations (command line vs explorer) stored in different places? Which one overrides which one, and does setting a new association with assoc and ftype overwrite that set in explorer?

What would you recommend to do, in order to be able to switch easily?


More info from my registry:

HKEY_CLASSES_ROOT.py is Python.File

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.py\Application is wordpad.exe

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.py\OpenWithProgids\Python.File is a binary value of length 0.

HKEY_LOCAL_MACHINE\SOFTWARE\Classes.py(Standard) is Python.File

More registry:

HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command开发者_开发百科(Standard) is still "C:\Program\Python27\python.exe" "%1" %*,

I suppose this is what is showing up in ftype Python.File. But it does not seem to get used.


Edit to add register information

Regedit says:

HKEY_CLASSES_ROOT\.py
   +--- (Standard)   REG_SZ   Python.File
   +--- Content Type REG_SZ   text/plain

I have tried changing the value of Content Type, no effect.

also:

HKEY_CLASSES_ROOT\Python.File
   +--- shell    (no data)
          +--- Edit with IDLE
          |      +--- command
          |             +--- (Standard)  <path-to-idle>
          +--- open (no data)
                 +--- command
                        +--- (Standard)  <path-to-python27>

I tried to set the value of shell to open, and the value of open to the path to the python27 exe, still not working. Somehow the command prompt still finds the association I made in winexplorer and uses wordpad to open the file, instead of using the command in open.


If HKEY_CLASSES_ROOT\.py is Python.File then you have to look into HKEY_CLASSES_ROOT\Python.File\shell. Then lookup the subkey named like its value, e.g. if the shell key has the value open go to HKEY_CLASSES_ROOT\Python.File\shell\open. That's where the association is stored. If the shell key has no value, go to the open subkey.

The problem is that the ftype tool always shows the contents of the open subkey regardless of the value of the shell key.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号