为什么 Windows 上的 virtualenv 不将 .py/.pyw/.pyo/.pyc 文件与 virtualenv 的 Python 可执行文件版本相关联? [英] Why doesn't virtualenv on Windows associate .py/.pyw/.pyo/.pyc files with virtualenv's version of Python executables?

查看:29
本文介绍了为什么 Windows 上的 virtualenv 不将 .py/.pyw/.pyo/.pyc 文件与 virtualenv 的 Python 可执行文件版本相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

virtualenv 没有将 .py(w) 文件与 virtualenv 版本的 Python 可执行文件相关联的原因是什么?考虑到没有像 shebang 在 Windows 上.

What is the reason virtualenv does not associate .py(w) files with virtualenv's version of Python executables? This seems like an ideal task for virtualenv on Windows taking into consideration that there's no mechanism like shebang on Windows.

推荐答案

文件类型关联在 Windows 注册表中处理.virtualenv 激活脚本必须修改注册表项,而去激活脚本需要恢复以前的值(或有破坏关联的风险).

File type associations are handled in the Windows registry. The virtualenv activate script would have to modify the registry keys and the deactivate script would need to restore the previous value (or risk breaking the associations).

如果您激活一个 virtualenv,打开 cmd.exe 的第二个实例,然后激活一个不同的 virtualenv,会发生什么?除非您以正确的顺序停用它们,否则注册表项的存储值将会丢失.

What happens if you activate a virtualenv, open a second instance of cmd.exe, and activate a different virtualenv? Unless you deactivate them in the right order, the stored values for the registry keys would be lost.

我不是 virtualenv 开发人员,我会说潜在的问题远远超过了微小的好处.

I'm not a virtualenv developer, I'd say that the potential problems far outweigh the slight benefit.

这篇关于为什么 Windows 上的 virtualenv 不将 .py/.pyw/.pyo/.pyc 文件与 virtualenv 的 Python 可执行文件版本相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆