How do I upgrade the Python installation in Windows 10?

前端 未结 5 1460
渐次进展
渐次进展 2020-11-28 18:50

I have a Python 2.7.11 installed on one of my LAB stations. I would like to upgrade Python to at least 3.5.

How should I do that ? Should I prefer to completely unin

5条回答
  •  独厮守ぢ
    2020-11-28 19:26

    If you are upgrading any 3.x.y to 3.x.z (patch) Python version, just go to Python downloads page get the latest version and start the installation. Since you already have Python installed on your machine installer will prompt you for "Upgrade Now". Click on that button and it will replace the existing version with a new one. You also will have to restart a computer after installation.

    If you are upgrading from 3.x to 3.y (minor) then you will be prompted with "Install Now". In this case, you are not upgrading, but you are installing a new version of Python. You can have more than one version installed on your machine. They will be located in different directories. When you have more than one Python version on your machine you will need to use py lanucher to launch a specific version of Python.

    For instance:

    py -3.7

    or

    py -3.8

    Make sure you have py launcher installed on your machine. It will be installed automatically if you are using default settings of windows installer. You can always check it if you click on "Customize installation" link on the installation window.

    If you have several Python versions installed on your machine and you have a project that is using the previous version of Python using virtual environment e.g. (venv) you can upgrade Python just in that venv using:

    python -m venv --upgrade "your virtual environment path"

    For instance, I have Python 3.7 in my ./venv virtual environment and I would like upgrade venv to Python 3.8, I would do following

    python -m venv --upgrade ./venv

提交回复
热议问题