差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| python:python_install [2019/08/08 07:08] – [Windows 編] ともやん | python:python_install [2020/09/11 16:59] (現在) – ともやん | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | <ifauth !@loggedinusers>< | ||
| - | <script async src="// | ||
| - | < | ||
| - | | ||
| - | google_ad_client: | ||
| - | enable_page_level_ads: | ||
| - | }); | ||
| - | </ | ||
| ====== Python のインストール ====== | ====== Python のインストール ====== | ||
| 行 13: | 行 5: | ||
| < | < | ||
| $ python3 -V | $ python3 -V | ||
| - | Python 3.7.4 | + | Python 3.8.1 |
| </ | </ | ||
| ===== Windows 編 ===== | ===== Windows 編 ===== | ||
| - | | + | |
| - | - ダウンロードした python-3.7.4-amd64.exe を実行して、[Customize installation] をクリックする。 | + | ==== Scoop によるインストール ==== |
| - | - Advanced Options の [v]Install for all users にチェックを入れて Customize install location を C:\Python37 | + | [[windows: |
| + | ダウンロード元として **versions** バケットを追加する。\\ | ||
| + | < | ||
| + | $ scoop bucket add versions | ||
| + | </ | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | Checking repo... ok | ||
| + | The versions bucket was added successfully. | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **python**、**python27** をインストールする。\\ | ||
| + | <code powershell> | ||
| + | $ scoop install python python27 | ||
| + | </ | ||
| + | <WRAP prewrap 100% # | ||
| + | <code powershell> | ||
| + | Installing ' | ||
| + | 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 ' | ||
| + | Creating shortcut for Less MSIérables (lessmsi-gui.exe) | ||
| + | ' | ||
| + | Installing ' | ||
| + | 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 ' | ||
| + | ' | ||
| + | Installing ' | ||
| + | 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 ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | ' | ||
| + | Notes | ||
| + | ----- | ||
| + | Allow applications and third-party installers to find python by running: | ||
| + | " | ||
| + | Installing ' | ||
| + | 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 ' | ||
| + | WARN Overwriting shim to python.exe installed from python | ||
| + | Creating shim for ' | ||
| + | WARN Overwriting shim to pythonw.exe installed from python | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | WARN Overwriting shim to idle.bat installed from python | ||
| + | Creating shim for ' | ||
| + | Running post-install script... | ||
| + | DEPRECATION: | ||
| + | Looking in links: c: | ||
| + | Collecting setuptools | ||
| + | Collecting pip | ||
| + | Installing collected packages: setuptools, pip | ||
| + | Successfully installed pip-19.2.3 setuptools-41.2.0 | ||
| + | ' | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **Visual Studio** などの外部アプリケーションが **Python** を自動検出できるようにする。\\ | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | Allow applications and third-party installers to find python by running: | ||
| + | " | ||
| + | </ | ||
| + | </ | ||
| + | <wrap hi> | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | 次のコマンドを実行して、アプリケーションとサードパーティのインストーラーがPythonを見つけられるようにします: | ||
| + | " | ||
| + | </ | ||
| + | </ | ||
| + | 以下のコマンドを実行して、Windows レジストリに **Python** を登録する。\\ | ||
| + | ([[https:// | ||
| + | <WRAP prewrap 100%> | ||
| + | <code powershell> | ||
| + | $ . $env: | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | 以下の問い合わせで「はい」をクリックする。\\ | ||
| + | {{python: | ||
| + | |||
| + | 「OK」をクリックする。\\ | ||
| + | {{python: | ||
| + | |||
| + | <WRAP prewrap 100% # | ||
| + | 必要に応じて RegEdit で以下のキーを確認する。\\ | ||
| + | < | ||
| + | HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore | ||
| + | </ | ||
| + | </ | ||
| + | {{python: | ||
| + | |||
| + | **python** の動作確認。\\ | ||
| + | < | ||
| + | $ python -VV | ||
| + | </ | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | Python 3.8.2 (tags/ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **python 2.7** へ切り替え。\\ | ||
| + | < | ||
| + | $ scoop reset python27 | ||
| + | </ | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | Resetting python27 (2.7.17). | ||
| + | Linking ~\scoop\apps\python27\current => ~\scoop\apps\python27\2.7.17 | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | Creating shim for ' | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ python -VV | ||
| + | </ | ||
| + | <WRAP prewrap 100% # | ||
| + | < | ||
| + | Python 3.8.2 (tags/ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Python 公式よりダウンロード ==== | ||
| + | | ||
| + | - ダウンロードした python-3.8.1-amd64.exe を実行して、[Customize installation] をクリックする。 | ||
| + | - Advanced Options の [v]Install for all users にチェックを入れて Customize install location を C:\Python38 | ||
| - [Install] をクリックする。 | - [Install] をクリックする。 | ||
| - インストールが終わったら [Disable path length limit] をクリックしておく。 | - インストールが終わったら [Disable path length limit] をクリックしておく。 | ||
| - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。 | - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。 | ||
| - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。 | - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。 | ||
| - | - システム環境変数の | + | - システム環境変数の |
| - | C:\Python37;C:\Python37\Scripts; | + | C:\Python38;C:\Python38\Scripts; |
| </ | </ | ||
| - コマンドラインにて動作確認を行う。< | - コマンドラインにて動作確認を行う。< | ||
| > python -V | > python -V | ||
| - | Python 3.7.4 | + | Python 3.8.1 |
| </ | </ | ||
| > python -VV | > python -VV | ||
| - | Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] | + | Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] |
| </ | </ | ||
| + | - pip をアップグレードする。< | ||
| + | > python -m pip install --upgrade pip | ||
| + | </ | ||
| + | Collecting pip | ||
| + | Using cached https:// | ||
| + | Installing collected packages: pip | ||
| + | Found existing installation: | ||
| + | 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: | ||
| + | </ | ||
| + | |||
| + | ==== Python 2.7/3.8 の共存 ==== | ||
| + | - Python 2.7 と Python 3.8 をインストールする。(2.7 と 3.8 のインストールの順番はどちらからでも良い) | ||
| + | - Python 2.7 は **C: | ||
| + | - Python 3.8 は **C: | ||
| + | - 環境変数の設定を行う。 | ||
| + | - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。 | ||
| + | -「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。 | ||
| + | -「環境変数」画面の [システム環境変数] の **Path** をダブルクリックする。 | ||
| + | - 存在しない場合は [新規] ボタンを押して以下のパスを追加する。< | ||
| + | C: | ||
| + | C: | ||
| + | C: | ||
| + | </ | ||
| + | - 既に存在する場合は以下の順番になる様にする。\\ {{: | ||
| + | - **Path** を設定したら [OK] ボタンで「環境変数名の編集」を閉じる。 | ||
| + | - 「環境変数」画面の [システム環境変数] の [新規] ボタンを押して以下の環境変数を登録する。< | ||
| + | 変数名: PY_PYTHONPATH | ||
| + | 変数値: 3 | ||
| + | </ | ||
| + | - 「環境変数」画面の [OK] ボタンを押して変更を反映させる。 | ||
| + | - コマンドプロンプト (cmd) を実行して Python の起動確認を行う。< | ||
| + | > py | ||
| + | Python 3.8.1 (tags/ | ||
| + | Type " | ||
| + | >>> | ||
| + | |||
| + | > py -2 | ||
| + | Python 2.7.17 (v2.7.17: | ||
| + | Type " | ||
| + | >>> | ||
| + | </ | ||
| + | - pip の起動確認を行う。< | ||
| + | > pip -V | ||
| + | pip 20.0.2 from c: | ||
| + | |||
| + | > pip2 -V | ||
| + | pip 19.2.3 from c: | ||
| + | |||
| + | > pip3 -V | ||
| + | pip 20.0.2 from c: | ||
| + | </ | ||
| + | - pip list を実行する。< | ||
| + | > pip2 list | ||
| + | DEPRECATION: | ||
| + | Package | ||
| + | ---------- ------- | ||
| + | pip 20.0.2 | ||
| + | setuptools 41.2.0 | ||
| + | virtualenv 16.7.4 | ||
| + | |||
| + | > pip3 list | ||
| + | Package | ||
| + | ---------- ------- | ||
| + | pip 20.0.2 | ||
| + | setuptools 41.2.0 | ||
| + | </ | ||
| + | - 以下の警告が出る場合は Python 2/3 の pip を更新する。< | ||
| + | WARNING: You are using pip version 19.2.3, however version 20.0.2 is available. | ||
| + | You should consider upgrading via the ' | ||
| + | </ | ||
| + | > py -2 -m pip install --upgrade pip | ||
| + | DEPRECATION: | ||
| + | Collecting pip | ||
| + | Using cached https:// | ||
| + | Installing collected packages: pip | ||
| + | Found existing installation: | ||
| + | Uninstalling pip-19.2.3: | ||
| + | Successfully uninstalled pip-19.2.3 | ||
| + | Successfully installed pip-20.0.2 | ||
| + | </ | ||
| + | > py -m pip install --upgrade pip | ||
| + | Collecting pip | ||
| + | Using cached https:// | ||
| + | Installing collected packages: pip | ||
| + | Found existing installation: | ||
| + | Uninstalling pip-19.2.3: | ||
| + | Successfully uninstalled pip-19.2.3 | ||
| + | Successfully installed pip-20.0.2 | ||
| + | </ | ||
| + | - **.py** の拡張子関連付けを **Python 3.8** に設定する。\\ コマンドプロンプトを管理者実行して以下のコマンドを実行する。< | ||
| + | > assoc .py | ||
| + | .py=Python.File | ||
| + | |||
| + | > ftype Python.File | ||
| + | Python.File=" | ||
| + | |||
| + | > ftype Python.File=" | ||
| + | Python.File=" | ||
| + | </ | ||
| + | |||
| + | === 参考文献 === | ||
| + | [[https:// | ||
| ===== Linux & Mac (pythonbrew) 編 ===== | ===== Linux & Mac (pythonbrew) 編 ===== | ||
| 行 95: | 行 347: | ||
| Python 3.2.3 | Python 3.2.3 | ||
| </ | </ | ||
| + | |||
| + | ===== 参考文献 ===== | ||
| + | [[https:// | ||