how to run code in different python versions

887 Views Asked by At

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. I have been trying to run them using different python version using shebang but it does not seem to work.

I'm currently using Visual Studio Code and even though I put shebang code like this #!"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?

2

There are 2 best solutions below

0
Hossein Heydari On

If you're using visual studio code, use ctrl + shift + p and choose specific interpreter for your code to run.

Other option is to make a virtualenv with the python version you need and run it your code there.

0
Matan Boas On

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