殆どの Linux には既に Python が入っています。
$ python3 -V Python 3.8.1
Scoop をインストールする。
ダウンロード元として versions バケットを追加する。
$ scoop bucket add versions
Checking repo... ok The versions bucket was added successfully.
python、python27 をインストールする。
$ scoop install python python27
Installing 'lessmsi' (1.6.91) [64bit] lessmsi-v1.6.91.zip (495.0 KB) [==============================================================================] 100% Checking hash of lessmsi-v1.6.91.zip ... ok. Extracting lessmsi-v1.6.91.zip ... done. Linking ~\scoop\apps\lessmsi\current => ~\scoop\apps\lessmsi\1.6.91 Creating shim for 'lessmsi'. Creating shortcut for Less MSIérables (lessmsi-gui.exe) 'lessmsi' (1.6.91) was installed successfully! Installing 'dark' (3.11.2) [64bit] dark-3.11.2.zip (3.5 MB) [====================================================================================] 100% Checking hash of dark-3.11.2.zip ... ok. Extracting dark-3.11.2.zip ... done. Linking ~\scoop\apps\dark\current => ~\scoop\apps\dark\3.11.2 Creating shim for 'dark'. 'dark' (3.11.2) was installed successfully! Installing 'python' (3.8.2) [64bit] install-pep-514.reg (555 B) [=================================================================================] 100% Checking hash of install-pep-514.reg ... ok. uninstall-pep-514.reg (86 B) [================================================================================] 100% Checking hash of uninstall-pep-514.reg ... ok. python-3.8.2-amd64.exe (26.3 MB) [============================================================================] 100% Checking hash of python-3.8.2-amd64.exe ... ok. Running pre-install script... Running installer script... Linking ~\scoop\apps\python\current => ~\scoop\apps\python\3.8.2 Creating shim for 'python'. Creating shim for 'pythonw'. Creating shim for 'python3'. Creating shim for 'idle'. Creating shim for 'idle3'. 'python' (3.8.2) was installed successfully! Notes ----- Allow applications and third-party installers to find python by running: "C:\Users\tomoyan\scoop\apps\python\current\install-pep-514.reg" Installing 'python27' (2.7.17) [64bit] python-2.7.17.amd64.msi (19.6 MB) [===========================================================================] 100% Checking hash of python-2.7.17.amd64.msi ... ok. Extracting python-2.7.17.amd64.msi ... done. Linking ~\scoop\apps\python27\current => ~\scoop\apps\python27\2.7.17 Creating shim for 'python'. WARN Overwriting shim to python.exe installed from python Creating shim for 'pythonw'. WARN Overwriting shim to pythonw.exe installed from python Creating shim for 'python2'. Creating shim for 'idle'. WARN Overwriting shim to idle.bat installed from python Creating shim for 'idle2'. Running post-install script... DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Looking in links: c:\users\tomoyan\appdata\local\temp\tmp1m0br9 Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-19.2.3 setuptools-41.2.0 'python27' (2.7.17) was installed successfully!
Visual Studio などの外部アプリケーションが Python を自動検出できるようにする。
Allow applications and third-party installers to find python by running: "C:\Users\tomoyan\scoop\apps\python\current\install-pep-514.reg"
重要 (翻訳):
次のコマンドを実行して、アプリケーションとサードパーティのインストーラーがPythonを見つけられるようにします: "C:\Users\tomoyan\scoop\apps\python\current\install-pep-514.reg"
以下のコマンドを実行して、Windows レジストリに Python を登録する。
(PEP 514 -- Python registration in the Windows registry | Python.org)
$ . $env:USERPROFILE\scoop\apps\python\current\install-pep-514.reg
必要に応じて RegEdit で以下のキーを確認する。
HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore
python の動作確認。
$ python -VV
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
python 2.7 へ切り替え。
$ scoop reset python27
Resetting python27 (2.7.17). Linking ~\scoop\apps\python27\current => ~\scoop\apps\python27\2.7.17 Creating shim for 'python'. Creating shim for 'pythonw'. Creating shim for 'python2'. Creating shim for 'idle'. Creating shim for 'idle2'.
$ python -VV
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
C:\Python38;C:\Python38\Scripts;C:\Program Files...
> python -V Python 3.8.1
> python -VV Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
> python -m pip install --upgrade pip
Collecting pip Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-20.0.2
> pip -V pip 20.0.2 from c:\python38\lib\site-packages\pip (python 3.8)
C:\Python38\ C:\Python38\Scripts\ C:\Python27\Scripts\
変数名: PY_PYTHONPATH 変数値: 3
> py Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> Ctrl + Z で Enter を押して終了 > py -2 Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> Ctrl + Z で Enter を押して終了
> pip -V pip 20.0.2 from c:\python38\lib\site-packages\pip (python 3.8) > pip2 -V pip 19.2.3 from c:\python27\lib\site-packages\pip (python 2.7) > pip3 -V pip 20.0.2 from c:\python38\lib\site-packages\pip (python 3.8)
> pip2 list DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Package Version ---------- ------- pip 20.0.2 setuptools 41.2.0 virtualenv 16.7.4 > pip3 list Package Version ---------- ------- pip 20.0.2 setuptools 41.2.0
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python 2 の pip を更新
> py -2 -m pip install --upgrade pip DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pip Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-20.0.2
Python 3 の pip を更新
> py -m pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-20.0.2
> assoc .py .py=Python.File > ftype Python.File Python.File="C:\Python27\python.exe" "%1" %* > ftype Python.File="C:\Python38\python.exe" "%1" %* Python.File="C:\Python38\python.exe" "%1" %*
ここでは pythonbrew を使って python をインストールします。
python 2.7.3 をインストールする。
$ pybrew install 2.7.3 Downloading Python-2.7.3.tgz as /Users/tomoyan/.pythonbrew/dists/Python-2.7.3.tgz ######################################################################## 100.0% Extracting Python-2.7.3.tgz into /Users/tomoyan/.pythonbrew/build/Python-2.7.3 This could take a while. You can run the following command on another shell to track the status: tail -f "/Users/tomoyan/.pythonbrew/log/build.log" Patching Python-2.7.3 Installing Python-2.7.3 into /Users/tomoyan/.pythonbrew/pythons/Python-2.7.3 Downloading distribute_setup.py as /Users/tomoyan/.pythonbrew/dists/distribute_setup.py ######################################################################## 100.0% Installing distribute into /Users/tomoyan/.pythonbrew/pythons/Python-2.7.3 Installing pip into /Users/tomoyan/.pythonbrew/pythons/Python-2.7.3 Installed Python-2.7.3 successfully. Run the following command to switch to Python-2.7.3. pythonbrew switch 2.7.3
python を切り替える
$ pybrew switch 2.7.3 Switched to Python-2.7.3 $ python -V Python 2.7.3
python 3.2.3 をインストールする。
$ pybrew install 3.2.3 Downloading Python-3.2.3.tgz as /Users/tomoyan/.pythonbrew/dists/Python-3.2.3.tgz ######################################################################## 100.0% Extracting Python-3.2.3.tgz into /Users/tomoyan/.pythonbrew/build/Python-3.2.3 This could take a while. You can run the following command on another shell to track the status: tail -f "/Users/tomoyan/.pythonbrew/log/build.log" Installing Python-3.2.3 into /Users/tomoyan/.pythonbrew/pythons/Python-3.2.3 Downloading distribute_setup.py as /Users/tomoyan/.pythonbrew/dists/distribute_setup.py ######################################################################## 100.0% Installing distribute into /Users/tomoyan/.pythonbrew/pythons/Python-3.2.3 Installing pip into /Users/tomoyan/.pythonbrew/pythons/Python-3.2.3 Installed Python-3.2.3 successfully. Run the following command to switch to Python-3.2.3. pythonbrew switch 3.2.3
python を切り替える
$ pybrew switch 3.2.3 Switched to Python-3.2.3 $ python -V Python 3.2.3