I have a piece of code I need to run but it is only compatible with tensorflow 1.3,1.4 and 1.5. I think I need to downgrade python in order to run this however the terminal has python 3.10
I have unsuccessfully tried to create a virtual environment but the terminal still says it is using python 3.10 so I am still unable to run the code is there anything I can do?
3
Answers
Please change the python version in VS code by selecting View -> Command Palette. Then select from the list of python version already installed. You can install multiple version of python and all will be listed.
The python version in your terminal is independent of the version you set in VSCode. The version in VSCode is used for instance for linting and running the program using the run button.
You can run a python program in the terminal using this command:
python[version] [...]
If you don’t specify a version, some default python version will be used (which one will be default depends on your system and python installation process, correct me if this is wrong).
You also can specify the major version:
python2
orpython3
, which will use again some default version.And you can use the full version consisting of the major and minor version. So you can use
python3.9
for Python 3.9 orpython3.12
for Python 3.12.Of course you can only use installed versions.
Changing the default version of the
python
command depends on your OS.This answer is assuming you’re on Windows.
When you enter simply
python
at the terminal, Windows will run the first version of Python that it finds in the PATH environment variables, which is typically the most recent version installed.To select a specific version, you can use the
py
command.First view all installed versions with
py -0
. The first column will shows the option flag to run that specific version.Now let’s say I want to create a virtual environment with version 3.9 using a subfolder named
.venv
, then I would run the commandThen I can activate the environment by running the appropriate activate script based on the type of terminal I’m using, and can confirm its the correct version.