skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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 or python3, 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 or python3.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.

    Login or Signup to reply.
  3. 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.

    $ py -0
     -V:3.12 *        Python 3.12 (64-bit)
     -V:3.11          Python 3.11 (64-bit)
     -V:3.10          Python 3.10 (64-bit)
     -V:3.9           Python 3.9 (64-bit)
     -V:3.8           Python 3.8 (64-bit)
    

    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 command

    py -V:3.9 -m venv .venv
    

    Then 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search