Programing

파이썬을 업데이트하는 방법?

crosscheck 2020. 7. 16. 08:15
반응형

파이썬을 업데이트하는 방법?


2012 년 초부터 버전 2.7을 설치했습니다. 최신 버전을 설치하기 전에이 버전을 완전히 제거하고 지 울지 여부에 대한 합의를 찾을 수 없습니다.

"소프트"-이전 버전을 제거 하시겠습니까? 이전 버전을 완전히 제거 / 삭제 하시겠습니까? 위에 설치 하시겠습니까?

필자는 파이썬 설치의 "세그먼트"방법을 사용하여 다른 버전을 분리하고 기능적으로 유지하면서 특수한 설치 / 업그레이드 프로세스를 보았습니다. 이것이 실제로 표준인지 확실하지 않습니다.

또한 Revo가 너무 과장되어 환경 / 경로 변수와 같이 여전히 필요한 잔재를 지우는 데 문제가 발생할 수 있는지 궁금합니다.

(Win7 x64, 32 비트 Python)


업데이트 : 2018-07-06

이 게시물은 이제 거의 5 살입니다! Python-2.7은 2020 년에 python.org로부터 공식 업데이트 수신을 중단합니다 . 또한 Python-3.7이 릴리스되었습니다 . 확인 파이썬 미래를 파이썬 3 파이썬-2 코드 호환되도록하는 방법. conda를 업데이트하려면 이제 conda update --all각 conda 환경에서 해당 패키지의 모든 패키지와 Python 실행 파일을 업데이트 할 것을 권장 합니다. 또한 이름이 Anaconda로 변경되었으므로 Windows 레지스트리 키가 여전히 같은지 모르겠습니다.

업데이트 : 2017-03-24

2015 년 6 월 이후 Python (x, y)에 대한 업데이트는 없었으므로 포기되었다고 가정하는 것이 안전하다고 생각합니다.

업데이트 : 2016-11-11

@cxw가 아래 에서 언급 했듯이 이러한 답변은 동일한 비트 버전에 대한 것이며 비트 버전은 64 비트와 32 비트를 의미합니다. 예를 들어,이 답변은 64 비트 Python-2.7.10에서 64 비트 Python-2.7.11 ( , 동일한 비트 버전) 로 업데이트하는 데 적용됩니다 . 서로 다른 두 가지 버전의 Python을 함께 설치할 수는 있지만 약간의 해킹이 필요하므로 독자를 위해이 연습을 저장하겠습니다. 해킹을 원하지 않으면 비트 버전을 전환하는 경우 다른 비트 버전을 먼저 제거하는 것이 좋습니다.

업데이트 : 2016-05-16
  • AnacondaMiniConda 는 Windows PATH및 레지스트리 변경 옵션을 비활성화하여 기존 Python 설치에서 사용할 수 있습니다 . 추출 후 PyPI conda에서 심볼릭 링크를 만들 bin거나 conda를 설치 하십시오 . 그런 다음라는 또 다른 심볼릭 링크 생성 conda-activateactivate아나콘다 / Miniconda 루트의 bin 폴더에 있습니다. 이제 Anaconda / Miniconda는 Ruby RVM과 같습니다. conda-activate rootAnaconda / Miniconda를 활성화 하는 데 사용하십시오.
  • 휴대용 파이썬은 더 이상 개발되거나 유지되지 않습니다.

TL; DR

  • Anaconda 또는 miniconda를 사용하여 conda update --all각 conda 환경을 최신 상태로 유지 하려면 실행하십시오 .
  • 동일한 주요 파이썬 버전 ( 예 : 2.7.5), 예전 버전 ( 예 : 2.7.4) 위에 설치
  • 공식 파이썬다른 주요 버전 ( 예 : 3.3), 오래된 버전과 나란히 설치하고 우성 ( 예 : 2.7) 을 가리 키도록 경로 / 연결을 설정 하고 다른 것으로 바로 가기 ( 예 : BASH $ ln /c/Python33/python.exe python3).

대답은 다음과 같습니다.

  1. OP에 2.7.x가 있고 최신 버전 2.7.x를 설치하려는 경우

    • 공식 Python 웹 사이트 에서 MSI 설치 프로그램사용하는 경우 이전 버전 위에 설치하면 설치 프로그램이 이전 버전을 제거하고 교체한다는 경고를 발행합니다. "제어판"의 "설치된 프로그램"에서 이전 버전이 새 버전으로 바뀌 었음을 확인합니다. 2.7.x의 최신 버전은 이전 버전과 호환되므로 완전히 안전하므로 IMHO 여러 버전의 2.7.x는 필요하지 않습니다.
    • 소스에서 빌드하는 경우 새롭고 깨끗한 디렉토리에 빌드 한 다음 모든 테스트를 통과하고 성공적으로 빌드되었다고 확신하면 새 빌드의 경로를 가리켜 야합니다. 소스에서 빌드하는 데 때때로 문제가있을 수 있으므로 빌드하십시오. SDK 7.0이 설치된 Windows 7에서 Python x64를 빌드하는 방법에 대한가이드를 참조하십시오 .
    • Python (x, y) 과 같은 배포판에서 설치하는 경우 해당 웹 사이트를 참조하십시오. 파이썬 (x, y) 은 버려졌습니다. 패키지 관리자를 사용하여 Python (x, y)에서 업데이트를 처리 할 수 ​​있다고 생각하지만 업데이트는 웹 사이트에도 포함되어 있습니다 . 특정 참조를 찾을 수 없으므로 다른 사람이 이에 대해 말할 수 있습니다. ActiveState 및 아마도 Enthought와 유사하게 Python (x, y)는 다른 Python 설치와 호환되지 않는다고 분명히 밝힙니다.

      Python (x, y)를 설치하기 전에 다른 Python 배포를 제거하는 것이 좋습니다.

    • Enthought 캐노피 MSI는을 사용하고로 중 하나를 설치합니다 Program Files\Enthought또는 home\AppData\Local\Enthought\Canopy\App모든 사용자 또는 각각 사용자 당. 기본 제공 업데이트 도구를 사용하여 최신 설치가 업데이트됩니다. 해당 설명서를 참조하십시오 .
    • ActiveState 는 또한 MSI를 사용하므로 이전 설치 위에 최신 설치를 설치할 수 있습니다. 설치 정보를 참조하십시오 .

      기타 Python 2.7 설치 Windows에서 ActivePython 2.7은 다른 Python 2.7 설치 (예 : python.org의 Python 2.7 빌드)와 공존 할 수 없습니다. ActivePython 2.7을 설치하기 전에 다른 Python 2.7 설치를 제거하십시오.

    • Sage 는 가상 머신에 설치하고이 용도로 사용할 수있는 Oracle VirtualBox 이미지 파일을 제공 할 것을 권장합니다. 업그레이드는 sage -upgrade명령 을 실행하여 내부적으로 처리됩니다 .
    • Anaconda다음 conda명령 을 사용하여 업데이트 할 수 있습니다 .

      conda update --all
      

      Anaconda / Miniconda를 사용하면 Python-2.6, 2.7, 3.3, 3.4 및 3.5를 포함한 여러 Python 버전을 관리 할 수있는 환경만들 수 있습니다 . 루트 Anaconda / Miniconda 설치는 현재 Python-2.7 또는 Python-3.5를 기반으로합니다.

      Anaconda는 다른 Python 설치를 방해 할 수 있습니다. 설치는 MSI 설치 프로그램을 사용합니다. [ 업데이트 : 2016-05-16] Anaconda 및 Miniconda는 이제 .exe설치 관리자를 사용하고 Windows PATH및 레지스트리 변경 을 비활성화하는 옵션을 제공 합니다.

      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 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.

    • WinPython updates, I think, can be handled through the WinPython Control Panel.
    • PortablePython is no longer being developed. It had no update method. Possibly updates could be unzipped into a fresh directory and then App\lib\site-packages and App\Scripts could be copied to the new installation, but if this didn't work then reinstalling all packages might have been necessary. Use pip list to see what packages were installed and their versions. Some were installed by PortablePython. Use easy_install pip to install pip if it wasn't installed.
  2. 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 (latest 2013-07-29)
    • C:\Python32 for 3.2.x
    • &c.
    • C:\Python27 for 2.7.x (latest 2013-07-29)
    • C:\Python26 for 2.6.x
    • &c.
  3. 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.


The best solution is to install the different Python versions in multiple paths.

eg. C:\Python27 for 2.7, and C:\Python33 for 3.3.

Read this for more info: How to run multiple Python versions on Windows


  • Official Python .msi installers are designed to replace:

    • any previous micro release (in x.y.z, z is "micro") because they are guaranteed to be backward-compatible and binary-compatible
    • a "snapshot" (built from source) installation with any micro version
  • A snapshot installer is designed to replace any snapshot with a lower micro version.

(See responsible code for 2.x, for 3.x)

Any other versions are not necessarily compatible and are thus installed alongside the existing one. If you wish to uninstall the old version, you'll need to do that manually. And also uninstall any 3rd-party modules you had for it:

  • If you installed any modules from bdist_wininst packages (Windows .exes), uninstall them before uninstalling the version, or the uninstaller might not work correctly if it has custom logic
  • modules installed with setuptools/pip that reside in Lib\site-packages can just be deleted afterwards
  • packages that you installed per-user, if any, reside in %APPDATA%/Python/PythonXY/site-packages and can likewise be deleted

I have always just installed the new version on top and never had any issues. Do make sure that your path is updated to point to the new version though.

참고URL : https://stackoverflow.com/questions/15102943/how-to-update-python

반응형