Search code examples
pythonversioncurses

How to install two python versions in one computer


I have Python 3.10 (64-bit) on my computer. And I use VS Code. I need to install Python 3.8 (64-bit) because I need to work with curses and it only works with Python 3.8.


Solution

  • For that, you can use virtual environments for example using Conda.

    1. Create a virtual environment for python 3.8. In the project folder run the following command
        conda create --name "your-desired-environment-name" python="python-version"
    

    e.g. to create a virtual environment for Python 3.8, run

       conda create --name env_python3.8 python=3.8
    
    1. Activate the created environment
        conda activate env_python3.8
    

    Then, in visual studio Code, you can easily switch from a virtual environment to another. That depends on the project that you are working on.

    The following How-to guide from VS Code can also be helpful.