Shebang/choose what version of Python a script is going to run

这一生的挚爱 提交于 2019-12-02 06:52:12
nekomatic

As mentioned in J. F. Sebastian's comment on this answer, the Python Launcher for Windows can select the Python version to run from a shebang line. According to the docs it's installed by default with Python 3.3 and later.

The windows shell does not use the shebang line to differentiate the file type. I am assuming you want to start your py file with different interpreter than default one.

You have 2 options:

  1. If you do not mix your version 2.7 py files and 3.5 py files in one folder, you can use virtualenv http://docs.python-guide.org/en/latest/dev/virtualenvs/

    That creates the isolated environment and is the very useful approach to isolation of any project.

  2. If you have those files mixed, you just create .bat file which sets the path to your Python 2.7 interpreter and executes the py file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!