python:python_install

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
python:python_install [2019/08/08 07:16] – [Windows 編] ともやんpython:python_install [2020/09/11 16:59] (現在) ともやん
行 1: 行 1:
-<ifauth !@loggedinusers><html> 
-<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> 
-<script> 
-     (adsbygoogle = window.adsbygoogle || []).push({ 
-          google_ad_client: "ca-pub-0791334967460971", 
-          enable_page_level_ads: true 
-     }); 
-</script></html></ifauth> 
 ====== Python のインストール ====== ====== Python のインストール ======
  
行 13: 行 5:
 <code> <code>
 $ python3 -V $ python3 -V
-Python 3.7.4+Python 3.8.1
 </code> </code>
  
 ===== Windows 編 ===== ===== Windows 編 =====
-  - [[https://www.python.org/|Welcome to Python.org]]の[[https://www.python.org/downloads/|Download Python | Python.org]]より最新バージョンをダウンロードしてくる。(ここでは [[https://www.python.org/ftp/python/3.7.4/python-3.7.4-amd64.exe|python-3.7.4-amd64.exe]] を使用する。) + 
-  - ダウンロードした python-3.7.4-amd64.exe を実行して、[Customize installation] をクリックする。 +==== Scoop によるインストール ==== 
-  - Advanced Options の [v]Install for all users にチェックを入れて Customize install location を C:\Python37 に変更する。(お好みで...)+[[windows:scoop|Scoop]] をインストールする。\\ 
 +ダウンロード元として **versions** バケットを追加する。\\ 
 +<code> 
 +$ scoop bucket add versions 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +Checking repo... ok 
 +The versions bucket was added successfully. 
 +</code> 
 +</WRAP> 
 + 
 +**python**、**python27** をインストールする。\\ 
 +<code powershell> 
 +$ scoop install python python27 
 +</code> 
 +<WRAP prewrap 100% #result_long> 
 +<code powershell> 
 +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! 
 +</code> 
 +</WRAP> 
 + 
 +**Visual Studio** などの外部アプリケーションが **Python** を自動検出できるようにする。\\ 
 +<WRAP prewrap 100% #mincode> 
 +<code> 
 +Allow applications and third-party installers to find python by running: 
 +"C:\Users\tomoyan\scoop\apps\python\current\install-pep-514.reg" 
 +</code> 
 +</WRAP> 
 +<wrap hi>**重要 (翻訳):**</wrap>\\ 
 +<WRAP prewrap 100% #mincode> 
 +<code> 
 +次のコマンドを実行して、アプリケーションとサードパーティのインストーラーがPythonを見つけられるようにします: 
 +"C:\Users\tomoyan\scoop\apps\python\current\install-pep-514.reg" 
 +</code> 
 +</WRAP> 
 +以下のコマンドを実行して、Windows レジストリに **Python** を登録する。\\ 
 +([[https://www.python.org/dev/peps/pep-0514/|PEP 514 -- Python registration in the Windows registry | Python.org]])\\ 
 +<WRAP prewrap 100%> 
 +<code powershell> 
 +$ . $env:USERPROFILE\scoop\apps\python\current\install-pep-514.reg 
 +</code> 
 +</WRAP> 
 + 
 +以下の問い合わせで「はい」をクリックする。\\ 
 +{{python:regedit_pep-514_001.png?400|RegEdit Python PEP-514 001}}\\ 
 + 
 +「OK」をクリックする。\\ 
 +{{python:regedit_pep-514_002.png?400|RegEdit Python PEP-514 002}}\\ 
 + 
 +<WRAP prewrap 100% #mincode> 
 +必要に応じて RegEdit で以下のキーを確認する。\\ 
 +<code> 
 +HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore 
 +</code> 
 +</WRAP> 
 +{{python:regedit_pep-514_003.png?640|RegEdit Python PEP-514 003}}\\ 
 + 
 +**python** の動作確認。\\ 
 +<code> 
 +$ python -VV 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] 
 +</code> 
 +</WRAP> 
 + 
 +**python 2.7** へ切り替え。\\ 
 +<code> 
 +$ scoop reset python27 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +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'
 +</code> 
 +</WRAP> 
 + 
 +<code> 
 +$ python -VV 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] 
 +</code> 
 +</WRAP> 
 + 
 + 
 +==== Python 公式よりダウンロード ==== 
 +  - [[https://www.python.org/|Welcome to Python.org]]の[[https://www.python.org/downloads/|Download Python | Python.org]]より最新バージョンをダウンロードしてくる。(ここでは [[https://www.python.org/ftp/python/3.8.1/python-3.8.1-amd64.exe|python-3.8.1-amd64.exe]] を使用する。) 
 +  - ダウンロードした 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 キーを押す。
   - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。   - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。
-  - システム環境変数の PATH に Python のフォルダ(C:\Python37;C:\Python37\Scripts;)を追加する。\\ PATH:\\ <code> +  - システム環境変数の Path に Python のフォルダ(C:\Python38;C:\Python38\Scripts;)を追加する。\\ Path:\\ <code> 
-C:\Python37;C:\Python37\Scripts;C:\Program Files...+C:\Python38;C:\Python38\Scripts;C:\Program Files...
 </code> </code>
   - コマンドラインにて動作確認を行う。<code>   - コマンドラインにて動作確認を行う。<code>
 > python -V > python -V
-Python 3.7.4+Python 3.8.1
 </code><code> </code><code>
 > python -VV > python -VV
-Python 3.7.(tags/v3.7.4:e09359112eJul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]+Python 3.8.(tags/v3.8.1:1b293b6Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
 </code> </code>
   - pip をアップグレードする。<code>   - pip をアップグレードする。<code>
-> pip install pip -U+python -m pip install --upgrade pip
 </code><WRAP prewrap 100%><code> </code><WRAP prewrap 100%><code>
 Collecting pip Collecting pip
-  Using cached https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl+  Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
 Installing collected packages: pip Installing collected packages: pip
-  Found existing installation: pip 19.0.3 +  Found existing installation: pip 19.2.3 
-    Uninstalling pip-19.0.3: +    Uninstalling pip-19.2.3: 
-      Successfully uninstalled pip-19.0.3+      Successfully uninstalled pip-19.2.3 
 +Successfully installed pip-20.0.2
 </code></WRAP><code> </code></WRAP><code>
 > pip -V > pip -V
-pip 19.2.from c:\python37\lib\site-packages\pip (python 3.7)+pip 20.0.from c:\python38\lib\site-packages\pip (python 3.8)
 </code> </code>
 +
 +==== Python 2.7/3.8 の共存 ====
 +  - Python 2.7 と Python 3.8 をインストールする。(2.7 と 3.8 のインストールの順番はどちらからでも良い)
 +    - Python 2.7 は **C:\Python27** に全てのユーザー共通でインストールする。
 +    - Python 3.8 は **C:\Python38** に全てのユーザー共通でインストールする。
 +  - 環境変数の設定を行う。
 +    - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。
 +    -「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。
 +    -「環境変数」画面の [システム環境変数] の **Path** をダブルクリックする。
 +      - 存在しない場合は [新規] ボタンを押して以下のパスを追加する。<code>
 +C:\Python38\
 +C:\Python38\Scripts\
 +C:\Python27\Scripts\
 +</code>
 +      - 既に存在する場合は以下の順番になる様にする。\\ {{:python:python_27_38_install_001.png?500|Python 2.7/3.8 共存 001}}
 +      - **Path** を設定したら [OK] ボタンで「環境変数名の編集」を閉じる。
 +    - 「環境変数」画面の [システム環境変数] の [新規] ボタンを押して以下の環境変数を登録する。<code>
 +変数名: PY_PYTHONPATH
 +変数値: 3
 +</code>
 +    - 「環境変数」画面の [OK] ボタンを押して変更を反映させる。
 +  - コマンドプロンプト (cmd) を実行して Python の起動確認を行う。<code>
 +> 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 を押して終了
 +</code>
 +  - pip の起動確認を行う。<code>
 +> 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)
 +</code>
 +  - pip list を実行する。<code>
 +> 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
 +</code>
 +    - 以下の警告が出る場合は Python 2/3 の pip を更新する。<code>
 +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.
 +</code>Python 2 の pip を更新<code>
 +> 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
 +</code>Python 3 の pip を更新<code>
 +> 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
 +</code>
 +  - **.py** の拡張子関連付けを **Python 3.8** に設定する。\\ コマンドプロンプトを管理者実行して以下のコマンドを実行する。<code>
 +> 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" %*
 +</code>
 +
 +=== 参考文献 ===
 +[[https://qiita.com/segur/items/23f276320216c3aa7cf7|WindowsにPython2.7とPython3.7が共存できるようにインストールする - Qiita]]\\
 +
 ===== Linux & Mac (pythonbrew) 編 ===== ===== Linux & Mac (pythonbrew) 編 =====
 ここでは [[python:pythonbrew]] を使って python をインストールします。 ここでは [[python:pythonbrew]] を使って python をインストールします。
行 107: 行 347:
 Python 3.2.3 Python 3.2.3
 </code> </code>
 +
 +===== 参考文献 =====
 +[[https://github.com/lukesampson/scoop/wiki/Switching-Ruby-And-Python-Versions|Switching Ruby and Python Versions · lukesampson/scoop Wiki]]\\
  
  • python/python_install.1565216165.txt.gz
  • 最終更新: 2019/08/08 07:16
  • by ともやん