winXP 上的 python 版本

发布于 2024-09-30 23:31:29 字数 1918 浏览 0 评论 0原文

我向超级用户提出了这个问题,并获得了风滚草徽章(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒眉千度 2024-10-07 23:31:29

如果 HKEY_CLASSES_ROOT\.pyPython.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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文