winXP 上的 python 版本
我向超级用户提出了这个问题,并获得了风滚草徽章(10 天内有 13 次浏览),所以我认为这里可能是正确的地方。
我的 Windows 机器上安装了多个版本的 python。我希望能够在默认使用的版本之间轻松切换。
我尝试并使用winexplorer来更改与py文件关联的程序。 我将用于打开这些文件的程序设置为写字板。 现在,当我在命令行中输入 .py 的文件名时,该文件会在写字板中打开。
尽管如此,在命令行中输入以下内容会产生:
C:\>assoc .py
.py=Python.File
C:\>ftype Python.File
Python.File="C:\Program\Python27\python.exe" "%1" %*
我不明白为什么命令行运行写字板(如 Windows 资源管理器中设置),尽管 assoc 和 ftype 说它应该运行 Python27。
这些关联(命令行与资源管理器)是否存储在不同的位置?哪一个会覆盖哪一个,并且设置与 assoc 和 ftype 的新关联是否会覆盖资源管理器中的设置?
为了能够轻松切换,您建议做什么?
来自我的注册表的更多信息:
HKEY_CLASSES_ROOT.py 是 Python.File
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.py\Application 是 wordpad.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.py\ OpenWithProgids\Python.File 是长度为 0 的二进制值。
HKEY_LOCAL_MACHINE\SOFTWARE\Classes.py(Standard) 是 Python.File
更多注册表:
HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command(Standard) 仍然是“C :\Program\Python27\python.exe" "%1" %*,
我想这就是 ftype Python.File 中显示的内容。但似乎不太习惯。
编辑添加注册信息
Regedit 说:
HKEY_CLASSES_ROOT\.py
+--- (Standard) REG_SZ Python.File
+--- Content Type REG_SZ text/plain
我已尝试更改 Content Type
的值,但没有效果。
另外:
HKEY_CLASSES_ROOT\Python.File
+--- shell (no data)
+--- Edit with IDLE
| +--- command
| +--- (Standard) <path-to-idle>
+--- open (no data)
+--- command
+--- (Standard) <path-to-python27>
我尝试将shell
的值设置为open
,并将open
的值设置为python27 exe的路径,仍然不起作用。 不知何故,命令提示符仍然找到我在 winexplorer 中所做的关联,并使用写字板打开文件,而不是使用 open
中的命令。
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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
HKEY_CLASSES_ROOT\.py
是Python.File
,那么您必须查看HKEY_CLASSES_ROOT\Python.File\shell
。然后查找与其值相似的子项,例如,如果shell
键的值为open
,则转到HKEY_CLASSES_ROOT\Python.File\shell\open
。这就是关联的存储位置。如果shell
键没有值,请转到open
子键。问题在于,ftype 工具始终显示
open
子项的内容,无论shell
键的值如何。If
HKEY_CLASSES_ROOT\.py
isPython.File
then you have to look intoHKEY_CLASSES_ROOT\Python.File\shell
. Then lookup the subkey named like its value, e.g. if theshell
key has the valueopen
go toHKEY_CLASSES_ROOT\Python.File\shell\open
. That's where the association is stored. If theshell
key has no value, go to theopen
subkey.The problem is that the ftype tool always shows the contents of the
open
subkey regardless of the value of theshell
key.