python 多个版本默认路径设置

2025-04-08 01:25:24
推荐回答(3个)
回答1:

linux下就很简单,在每个py文件第一行加上如下的内容即可:
#!/usr/bin/python27
或者
#!/usr/bin/env python3

而windows是根据文件扩展名绑定的,所以上述设置无效。
只能强制指定解释器:
方法一:鼠标右键菜单->打开方式->python相应版本的解释器
方法二:在控制台或bat文件中指定:/path/to/python25.exe myprogram.py

回答2:

什么系统呢?win还是linux或其他?

回答3:

I guess all your interpreters are called python.exe. If so changing the 'Opens with' tag may not work correctly. (I didn't check , But I think the windows just check for the exe path from the environment variable 'path')

My opinion, you can rename the interpreters, like python25.exe python26.exe python27.exe.
Now you can set the one you want.

you may try if this helps.