简体   繁体   English

如何在不同的 python 版本中运行代码

[英]how to run code in different python versions

I have two python scripts and one of them runs on python 3.8.6 64bit and the other runs on python 3.8.6 32bit version.我有两个 python 脚本,其中一个运行在 python 3.8.6 64 位版本上,另一个运行在 python 3.8.6 32 位版本上。 I have been trying to run them using different python version using shebang but it does not seem to work.我一直在尝试使用 shebang 使用不同的 python 版本运行它们,但它似乎不起作用。

I'm currently using Visual Studio Code and even though I put shebang code like this #:"C./Python/3.8.6/64/python.exe"我目前正在使用 Visual Studio Code,即使我像这样放置 shebang 代码 #:"C./Python/3.8.6/64/python.exe"

it does not change the python version the script is running Is there a way to make python code to run at specific version?它不会更改脚本正在运行的 python 版本有没有办法让 python 代码在特定版本上运行?

If you're using visual studio code, use ctrl + shift + p and choose specific interpreter for your code to run.如果您使用的是 Visual Studio 代码,请使用ctrl + shift + p并为要运行的代码选择特定的解释器。

Other option is to make a virtualenv with the python version you need and run it your code there.另一种选择是使用您需要的 python 版本创建一个 virtualenv,并在那里运行您的代码。

Press CTRL + SHIFT + P and search for open user settings In there search for this setting: Python: python interpreter Then you can change the path of your python interpreter按 CTRL + SHIFT + P 并搜索打开的用户设置 在那里搜索此设置: Python: python 解释器 然后您可以更改 python 解释器的路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python 命令从不同版本的 python 运行 pip? - How to run pip from different versions of python using the python command? 如何针对不同版本的python运行py.test? - How to run py.test against different versions of python? 如何同时使用两个 OpenCV 版本 python 运行代码? - How to run the code using two OpenCV versions python at the same time? 在Linux中,如何为不同版本的Python编译和安装代码? - In Linux, how do I compile and install code for different versions of Python? 在不同的 python 补丁版本上运行 tox - run tox on different python patch versions 如果 pyenv 设置为针对 python 的多个版本运行,如何运行 python 代码 - How to run python code if pyenv is setup to run against multiple versions of python 尝试使用 mod_wsgi 运行 2 个具有不同 Python 版本的 Python 应用程序 - Trying to run 2 Python applications with different Python versions with mod_wsgi 如何在 anaconda\\env 中从 komodo edit 设置和运行不同的 python3 环境版本? - how to set and run different python3 environment versions from komodo edit while in anaconda\env? 针对不同语言版本运行代码覆盖是否有意义? - Does it make sense to run code coverage against different language versions? 在特定的 gpu 上运行 python 代码以获得较低的 python 版本 - Run python code on specific gpu for lower python versions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM