Search code examples
pycharmvirtualenvpython-venvvirtual-environment

Pycharm change venv python from 3.6 to 3.7 without creating all enviroment from strach


I work on pycharm project and I have a virtual environment (venv) with Python version 3.6.

I need to change it to 3.7 but I don't want to have to create a new environment and install all the packages from the beginning. Is there a way to do that? Just change the python version while keeping all the packages?


Solution

  • Unfortunately what you are looking for is not possible.

    Your solution is to create a requirements.txt file from your current environment, create a new one with Python 3.7 and re-install the packages.

    To create the file, issue this while your current environment is active:

    pip freeze > requirements.txt

    And then, this one when the new environment is installed and active:

    pip install -r /path/to/requirements.txt

    P.S: requirements.txt is just a name everyone uses. It's not written in stone. Use any filename you want.