如何在Windows 10中升级Python安装?

时间:2022-12-03 22:58:23

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.

我在我的一个LAB工作站上安装了Python 2.7.11。我想将Python升级到至少3.5。

How should I do that ? Should I prefer to completely uninstall 2.7.11 and than install the new one ? Is there a way to update it ? Is an update a good idea ?

我该怎么做?我是否应该完全卸载2.7.11而不是安装新的?有没有办法更新它?更新是个好主意吗?

3 个解决方案

#1


24  

Every minor version of Python, that is any 3.x and 2.x version, will install side-by-side with other versions on your computer. Only patch versions will upgrade existing installations.

每个次要版本的Python,即任何3.x和2.x版本,都将与您计算机上的其他版本并行安装。只有补丁版本才会升级现有安装。

So if you want to keep your installed Python 2.7 around, then just let it and install a new version using the installer. If you want to get rid of Python 2.7, you can uninstall it before or after installing a newer version—there is no difference to this.

因此,如果您想保持已安装的Python 2.7,那么只需使用安装程序即可安装新版本。如果你想摆脱Python 2.7,可以在安装新版本之前或之后卸载它 - 这没有区别。

Current Python 3 installations come with the py.exe launcher, which by default is installed into the system directory. This makes it available from the PATH, so you can automatically run it from any shell just by using py instead of python as the command. This avoids you having to put the current Python installation into PATH yourself. That way, you can easily have multiple Python installations side-by-side without them interfering with each other. When running, just use py script.py instead of python script.py to use the launcher. You can also specify a version using for example py -3 or py -3.6 to launch a specific version, otherwise the launcher will use the current default (which will usually be the latest 3.x).

当前的Python 3安装附带py.exe启动程序,默认情况下安装在系统目录中。这使得它可以从PATH中获得,因此您可以通过使用py而不是python作为命令从任何shell自动运行它。这避免了您必须自己将当前的Python安装放入PATH。这样,您可以轻松地并排进行多个Python安装,而不会相互干扰。运行时,只需使用py script.py而不是python script.py来使用启动器。您还可以使用例如py -3或py -3.6指定版本以启动特定版本,否则启动器将使用当前默认值(通常是最新的3.x)。

Using the launcher, you can also run Python 2 scripts (which are often syntax incompatible to Python 3), if you decide to keep your Python 2.7 installation. Just use py -2 script.py to launch a script.

如果您决定继续安装Python 2.7,那么使用启动器,您还可以运行Python 2脚本(通常与Python 3不兼容)。只需使用py -2 script.py启动脚本即可。


As for PyPI packages, every Python installation comes with its own folder where modules are installed into. So if you install a new version and you want to use modules you installed for a previous version, you will have to install them first for the new version. Current versions of the installer also offer you to install pip; it’s enabled by default, so you already have pip for every installation. Unless you explicitly add a Python installation to the PATH, you cannot just use pip though. Luckily, you can also simply use the py.exe launcher for this: py -m pip runs pip. So for example to install Beautiful Soup for Python 3.6, you could run py -3.6 -m pip install beautifulsoup4.

至于PyPI包,每个Python安装都有自己的文件夹,其中安装了模块。因此,如果您安装新版本并且想要使用为先前版本安装的模块,则必须先为新版本安装它们。当前版本的安装程序还可以安装pip;它默认启用,因此您已经拥有每个安装的pip。除非您明确地向PATH添加Python安装,否则不能只使用pip。幸运的是,你也可以简单地使用py.exe启动器:py -m pip运行pip。因此,例如为Python 3.6安装Beautiful Soup,你可以运行py -3.6 -m pip install beautifulsoup4。

#2


6  

You can use pip to upgrade a package. It is super easy and recommended too.

您可以使用pip升级包。它也非常简单,也值得推荐。

pip install python --upgrade OR pip install python -U

pip install python --upgrade或pip install python -U

You dont need to uninstall python27. Just set the path of whatever version you like to use as a primary one and use it. Ref : Click here

你不需要卸载python27。只需设置您希望用作主要版本的版本的路径并使用它。参考:点击这里

Sure upgrade is a good idea if you're in the learning phase.

如果你正处于学习阶段,肯定升级是个好主意。

#3


2  

Python 2.x and Python 3.x are different. If you would like to download a newer version of Python 2, you could just download and install the newer version.

Python 2.x和Python 3.x是不同的。如果您想下载更新版本的Python 2,您可以下载并安装更新版本。

If you want to install Python 3, you could install Python 3 separately then change the path for Python 2.x to Python 3.x in Control Panel > All Control Panel Items > System > Advanced System Settings > Environment Variables.

如果要安装Python 3,可以单独安装Python 3,然后在控制面板>所有控制面板项>系统>高级系统设置>环境变量中将Python 2.x的路径更改为Python 3.x.

#1


24  

Every minor version of Python, that is any 3.x and 2.x version, will install side-by-side with other versions on your computer. Only patch versions will upgrade existing installations.

每个次要版本的Python,即任何3.x和2.x版本,都将与您计算机上的其他版本并行安装。只有补丁版本才会升级现有安装。

So if you want to keep your installed Python 2.7 around, then just let it and install a new version using the installer. If you want to get rid of Python 2.7, you can uninstall it before or after installing a newer version—there is no difference to this.

因此,如果您想保持已安装的Python 2.7,那么只需使用安装程序即可安装新版本。如果你想摆脱Python 2.7,可以在安装新版本之前或之后卸载它 - 这没有区别。

Current Python 3 installations come with the py.exe launcher, which by default is installed into the system directory. This makes it available from the PATH, so you can automatically run it from any shell just by using py instead of python as the command. This avoids you having to put the current Python installation into PATH yourself. That way, you can easily have multiple Python installations side-by-side without them interfering with each other. When running, just use py script.py instead of python script.py to use the launcher. You can also specify a version using for example py -3 or py -3.6 to launch a specific version, otherwise the launcher will use the current default (which will usually be the latest 3.x).

当前的Python 3安装附带py.exe启动程序,默认情况下安装在系统目录中。这使得它可以从PATH中获得,因此您可以通过使用py而不是python作为命令从任何shell自动运行它。这避免了您必须自己将当前的Python安装放入PATH。这样,您可以轻松地并排进行多个Python安装,而不会相互干扰。运行时,只需使用py script.py而不是python script.py来使用启动器。您还可以使用例如py -3或py -3.6指定版本以启动特定版本,否则启动器将使用当前默认值(通常是最新的3.x)。

Using the launcher, you can also run Python 2 scripts (which are often syntax incompatible to Python 3), if you decide to keep your Python 2.7 installation. Just use py -2 script.py to launch a script.

如果您决定继续安装Python 2.7,那么使用启动器,您还可以运行Python 2脚本(通常与Python 3不兼容)。只需使用py -2 script.py启动脚本即可。


As for PyPI packages, every Python installation comes with its own folder where modules are installed into. So if you install a new version and you want to use modules you installed for a previous version, you will have to install them first for the new version. Current versions of the installer also offer you to install pip; it’s enabled by default, so you already have pip for every installation. Unless you explicitly add a Python installation to the PATH, you cannot just use pip though. Luckily, you can also simply use the py.exe launcher for this: py -m pip runs pip. So for example to install Beautiful Soup for Python 3.6, you could run py -3.6 -m pip install beautifulsoup4.

至于PyPI包,每个Python安装都有自己的文件夹,其中安装了模块。因此,如果您安装新版本并且想要使用为先前版本安装的模块,则必须先为新版本安装它们。当前版本的安装程序还可以安装pip;它默认启用,因此您已经拥有每个安装的pip。除非您明确地向PATH添加Python安装,否则不能只使用pip。幸运的是,你也可以简单地使用py.exe启动器:py -m pip运行pip。因此,例如为Python 3.6安装Beautiful Soup,你可以运行py -3.6 -m pip install beautifulsoup4。

#2


6  

You can use pip to upgrade a package. It is super easy and recommended too.

您可以使用pip升级包。它也非常简单,也值得推荐。

pip install python --upgrade OR pip install python -U

pip install python --upgrade或pip install python -U

You dont need to uninstall python27. Just set the path of whatever version you like to use as a primary one and use it. Ref : Click here

你不需要卸载python27。只需设置您希望用作主要版本的版本的路径并使用它。参考:点击这里

Sure upgrade is a good idea if you're in the learning phase.

如果你正处于学习阶段,肯定升级是个好主意。

#3


2  

Python 2.x and Python 3.x are different. If you would like to download a newer version of Python 2, you could just download and install the newer version.

Python 2.x和Python 3.x是不同的。如果您想下载更新版本的Python 2,您可以下载并安装更新版本。

If you want to install Python 3, you could install Python 3 separately then change the path for Python 2.x to Python 3.x in Control Panel > All Control Panel Items > System > Advanced System Settings > Environment Variables.

如果要安装Python 3,可以单独安装Python 3,然后在控制面板>所有控制面板项>系统>高级系统设置>环境变量中将Python 2.x的路径更改为Python 3.x.