如何更新Python? [英] How to update Python?

查看:111
本文介绍了如何更新Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从2012年初开始安装2.7版.对于在安装最新版本之前是否应该完全卸载并擦除此版本,我无法达成共识.

I have version 2.7 installed from early 2012. I can't find any consensus on whether I should completely uninstall and wipe this version before putting on the latest version.

软"-删除旧版本吗?硬删除/清除旧版本?在顶部安装?

"Soft"-removing old versions? Hard-removing/wiping old versions? Installing over top?

我在某处看到了一个特殊的安装/升级过程,该过程使用Python安装的分段"方法,将不同的版本分开并保持功能.不确定这是否是事实上的标准.

I've seen somewhere a special install/upgrade process using a "segmenting" method of Python installations, keeping different versions separate and apart, but functional. Not sure if this is the standard, de facto way.

我还想知道Revo是否太过热情,是否可能导致清除仍然需要的残留物(例如环境/PATH变量)的问题.

I also wonder if Revo gets too overzealous and may cause issues with wiping out still-needed remnants, like environment/PATH variables.

(Win7 x64,32位Python)

(Win7 x64, 32-bit Python)

推荐答案

更新:2018年7月6日

这个帖子现在已经快5年了! Python-2.7将于2020年停止接收来自python.org的官方更新.另外, Python-3.7已发布.查看 Python未来,了解如何使您的Python-2代码与Python-3兼容.为了更新conda,文档现在建议在每个conda环境中使用conda update --all来更新该版本的所有软件包和Python可执行文件.另外,由于它们将名称更改为Anaconda,所以我不知道Windows注册表项是否仍然相同.

UPDATE: 2018-07-06

This post is now nearly 5 years old! Python-2.7 will stop receiving official updates from python.org in 2020. Also, Python-3.7 has been released. Check out Python-Future on how to make your Python-2 code compatible with Python-3. For updating conda, the documentation now recommends using conda update --all in each of your conda environments to update all packages and the Python executable for that version. Also, since they changed their name to Anaconda, I don't know if the Windows registry keys are still the same.

自2015年6月以来,没有对Python(x,y)进行任何更新,因此我可以肯定地认为它已被放弃.

There have been no updates to Python(x,y) since June of 2015, so I think it's safe to assume it has been abandoned.

作为下面的@cxw注释,这些答案是相同的.版本,按位版本,我的意思是64位与32位.例如,这些答案适用于从64位Python-2.7.10升级到64位Python-2.7.11, ie :相同位版本.虽然可以将两个不同版本的Python一起安装,但这需要进行一些修改,因此我将为读者保存该练习.如果您不想黑客,我建议如果切换位版本,请先删除其他位版本.

As @cxw comments below, these answers are for the same bit-versions, and by bit-version I mean 64-bit vs. 32-bit. For example, these answers would apply to updating from 64-bit Python-2.7.10 to 64-bit Python-2.7.11, ie: the same bit-version. While it is possible to install two different bit versions of Python together, it would require some hacking, so I'll save that exercise for the reader. If you don't want to hack, I suggest that if switching bit-versions, remove the other bit-version first.

  • Anaconda and MiniConda can be used with an existing Python installation by disabling the options to alter the Windows PATH and Registry. After extraction, create a symlink to conda in your bin or install conda from PyPI. Then create another symlink called conda-activate to activate in the Anaconda/Miniconda root bin folder. Now Anaconda/Miniconda is just like Ruby RVM. Just use conda-activate root to enable Anaconda/Miniconda.
  • Portable Python is no longer being developed or maintained.
  • 使用 Anaconda或miniconda ,然后只需执行conda update --all即可更新每个conda环境,
  • 相同的主要版本的官方Python ( eg 2.7.5),只需安装在旧版本( eg 2.7.4)上,
  • 官方Python
  • 不同的主要版本( ( eg 3.3),与旧版本并排安装,设置路径/关联以指向主要( eg 2.7),捷径指向其他( eg $ ln /c/Python33/python.exe python3中的em>.
  • Using Anaconda or miniconda, then just execute conda update --all to keep each conda environment updated,
  • same major version of official Python (e.g. 2.7.5), just install over old (e.g. 2.7.4),
  • different major version of official Python (e.g. 3.3), install side-by-side with old, set paths/associations to point to dominant (e.g. 2.7), shortcut to other (e.g. in BASH $ ln /c/Python33/python.exe python3).
  1. 如果OP的版本为2.7.x,并且要安装较新的版本2.7.x,则

  1. If OP has 2.7.x and wants to install newer version of 2.7.x, then

  • 如果使用来自 MSI安装程序 .org/download/"rel =" noreferrer>官方Python网站,只需在旧版本上安装,安装程序就会发出警告,指出它将删除并替换旧版本;在确认旧版本已被新版本替换"之前和之后,在控制面板"中查看已安装程序";较新版本的2.7.x是向后兼容的,因此这是完全安全的,因此,IMHO多个版本的2.7.x永远不需要.
  • 如果从源代码构建,则您可能应该构建在一个全新的干净目录中,一旦通过所有测试并且确信已成功构建,则将您的路径指向新构建,但是您可能希望保留旧版本,因为从源构建有时可能会遇到问题.请参阅我的在Windows上构建Python x64的指南7 with SDK 7.0 .
  • 如果通过 Python(x,y)之类的发行版进行安装,请访问其网站. Python(x,y)已被放弃. 我相信可以使用其程序包管理器在Python(x,y)内处理更新,但更新也包含在其网站上.我找不到具体的参考,所以也许其他人可以对此发表意见.与ActiveState相似,并且可能是有思想的,Python(x,y)明确指出它与Python的其他安装不兼容:
  • if using MSI installer from the official Python website, just install over old version, installer will issue warning that it will remove and replace the older version; looking in "installed programs" in "control panel" before and after confirms that the old version has been replaced by the new version; newer versions of 2.7.x are backwards compatible so this is completely safe and therefore IMHO multiple versions of 2.7.x should never necessary.
  • if building from source, then you should probably build in a fresh, clean directory, and then point your path to the new build once it passes all tests and you are confident that it has been built successfully, but you may wish to keep the old build around because building from source may occasionally have issues. See my guide for building Python x64 on Windows 7 with SDK 7.0.
  • if installing from a distribution such as Python(x,y), see their website. Python(x,y) has been abandoned. I believe that updates can be handled from within Python(x,y) with their package manager, but updates are also included on their website. I could not find a specific reference so perhaps someone else can speak to this. Similar to ActiveState and probably Enthought, Python (x,y) clearly states it is incompatible with other installations of Python:

建议在安装Python(x,y)之前先卸载所有其他Python发行版

It is recommended to uninstall any other Python distribution before installing Python(x,y)

  • 思想冠层使用MSI,并将全部安装到Program Files\Enthoughthome\AppData\Local\Enthought\Canopy\App中个用户或每个用户.通过使用内置的更新工具来更新较新的安装.请参阅其文档.
  • ActiveState 也使用MSI,因此可以在较旧的安装之上安装较新的安装.请参阅他们的安装说明.

  • Enthought Canopy uses an MSI and will install either into Program Files\Enthought or home\AppData\Local\Enthought\Canopy\App for all users or per user respectively. Newer installations are updated by using the built in update tool. See their documentation.
  • ActiveState also uses an MSI so newer installations can be installed on top of older ones. See their installation notes.

    其他Python 2.7安装在Windows上,ActivePython 2.7无法与其他Python 2.7安装共存(例如,来自python.org的Python 2.7构建).在安装ActivePython 2.7之前,请先卸载其他Python 2.7安装.

    Other Python 2.7 Installations On Windows, ActivePython 2.7 cannot coexist with other Python 2.7 installations (for example, a Python 2.7 build from python.org). Uninstall any other Python 2.7 installations before installing ActivePython 2.7.

  • Sage 建议您将其安装到虚拟机中,并提供一个Oracle VirtualBox可以用于此目的的图像文件.发出sage -upgrade命令在内部处理升级.
  • Anaconda 可以是

  • Sage recommends that you install it into a virtual machine, and provides a Oracle VirtualBox image file that can be used for this purpose. Upgrades are handled internally by issuing the sage -upgrade command.
  • Anaconda can be updated by using the conda command:

    conda update --all
    

    Anaconda/Miniconda使用户可以创建环境来管理多个Python版本,包括Python-2.6、2.7、3.3、3.4和3.5. Anaconda/Miniconda的根安装当前基于Python-2.7或Python-3.5.

    Anaconda/Miniconda lets users create environments to manage multiple Python versions including Python-2.6, 2.7, 3.3, 3.4 and 3.5. The root Anaconda/Miniconda installations are currently based on either Python-2.7 or Python-3.5.

    Anaconda可能会破坏任何其他Python安装.安装使用MSI安装程序. [更新:2016-05-16] Anaconda和Miniconda现在使用.exe安装程序,并提供用于禁用Windows PATH和注册表更改的选项.

    Anaconda will likely disrupt any other Python installations. Installation uses MSI installer. [UPDATE: 2016-05-16] Anaconda and Miniconda now use .exe installers and provide options to disable Windows PATH and Registry alterations.

    因此,可以根据自己的安装方式和安装过程中选择的选项,在不中断现有Python安装的情况下安装Anaconda/Miniconda.如果使用.exe安装程序,并且 禁用了更改Windows PATH和注册表的选项,则将禁用所有以前的Python安装 ,而只需卸载Anaconda/Miniconda安装应恢复原始的Python安装,但Windows注册表Python\PythonCore键除外.

    Therefore Anaconda/Miniconda can be installed without disrupting existing Python installations depending on how it was installed and the options that were selected during installation. If the .exe installer is used and the options to alter Windows PATH and Registry are not disabled, then any previous Python installations will be disabled, but simply uninstalling the Anaconda/Miniconda installation should restore the original Python installation, except maybe the Windows Registry Python\PythonCore keys.

    Anaconda/Miniconda不管安装选项如何,都会进行以下注册表HKCU\Software\Python\ContinuumAnalytics\具有以下项:HelpInstallPathModulesPythonPath-官方Python也注册了这些项,但在Python\PythonCore.还为Anaconda \ Miniconda注册了卸载信息.除非在安装过程中选择在Windows中注册"选项,否则它不会创建PythonCore,因此像Visual Studio的Python工具这样的集成不会自动看到Anaconda/Miniconda.如果启用了注册Anaconda/Miniconda 的选项,那么我认为您现有的Python Windows注册表项将被更改,并且卸载可能不会恢复它们.

    Anaconda/Miniconda makes the following registry edits regardless of the installation options: HKCU\Software\Python\ContinuumAnalytics\ with the following keys: Help, InstallPath, Modules and PythonPath - official Python registers these keys too, but under Python\PythonCore. Also uninstallation info is registered for Anaconda\Miniconda. Unless you select the "Register with Windows" option during installation, it doesn't create PythonCore, so integrations like Python Tools for Visual Studio do not automatically see Anaconda/Miniconda. If the option to register Anaconda/Miniconda is enabled, then I think your existing Python Windows Registry keys will be altered and uninstallation will probably not restore them.

    如果OP具有2.7.x,并且要安装其他版本,则 eg < = 2.6.x或> = 3.xx,然后并排安装不同版本很好您必须选择要与*.py文件关联的Python版本(如果有),以及要在路径中使用的版本,但是如果使用

    If OP has 2.7.x and wants to install a different version, e.g. <=2.6.x or >=3.x.x, then installing different versions side-by-side is fine. You must choose which version of Python (if any) to associate with *.py files and which you want on your path, although you should be able to set up shells with different paths if you use BASH. AFAIK 2.7.x is backwards compatible with 2.6.x, so IMHO side-by-side installs is not necessary, however Python-3.x.x is not backwards compatible, so my recommendation would be to put Python-2.7 on your path and have Python-3 be an optional version by creating a shortcut to its executable called python3 (this is a common setup on Linux). The official Python default install path on Windows is

    • C:\ Python33 for 3.3.x(最新2013-07-29)
    • C:\ Python32 for 3.2.x
    • & c.
    • C:\ Python27 for 2.7.x(2013-07-29最新)
    • C:\ Python26 for 2.6.x
    • & c.

    如果OP不是在更新Python,而只是在更新软件包,他们可能希望研究 virtualenv ,以使其开发项目专用的软件包的不同版本分开. Pip 也是更新软件包的好工具.如果软件包使用二进制安装程序,我通常会在安装新软件包之前先卸载旧软件包.

    If OP is not updating Python, but merely updating packages, they may wish to look into virtualenv to keep the different versions of packages specific to their development projects separate. Pip is also a great tool to update packages. If packages use binary installers I usually uninstall the old package before installing the new one.

    我希望这可以消除任何混乱.

    I hope this clears up any confusion.

    这篇关于如何更新Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆