我有一个Python 2.7.11安装在我的实验室站之一。我想把Python升级到至少3.5。
我该怎么做呢? 我应该完全卸载2.7.11,而不是安装新的版本吗? 有办法更新吗?更新是个好主意吗?
我有一个Python 2.7.11安装在我的实验室站之一。我想把Python升级到至少3.5。
我该怎么做呢? 我应该完全卸载2.7.11,而不是安装新的版本吗? 有办法更新吗?更新是个好主意吗?
当前回答
现在你只需要从微软商店安装几个Python版本就可以了。这些都是由Python软件基金会发布的。
https://apps.microsoft.com/store/search?hl=en-en&gl=EN&publisher=Python%20Software%20Foundation
其他回答
我能够使用以下命令执行PowerShell,并且python升级没有问题。Python -m PIP install——upgrade PIP please see image
现在你只需要从微软商店安装几个Python版本就可以了。这些都是由Python软件基金会发布的。
https://apps.microsoft.com/store/search?hl=en-en&gl=EN&publisher=Python%20Software%20Foundation
Python 2。3. Python。X是不同的。如果您想下载Python 2的新版本,只需下载并安装新版本即可。
如果你想安装Python 3,你可以单独安装Python 3,然后更改Python 2的路径。3.使用Python。>所有控制面板项>系统>高级系统设置>环境变量。
每一个小版本的Python,都是任意3。X和2。X版本,将与其他版本并排安装在您的计算机上。只有补丁版本才会升级现有的安装。
因此,如果你想保留你已经安装的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 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.
对我来说,一个快速而无痛的方法是这样做:
在我受影响的环境上执行pip freeze > requirements.txt(或任何您想要备份您的需求的方法) 删除旧版本的Python(在我的情况下是3.8) 移除相关的环境 安装新版本(在我的例子中是3.9.5) 重新创建我的环境python -m venv venv或任何您希望的方式 重新安装我的插件/应用程序pip install -r requirements.txt或任何你想要的