python:python_install

差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
次のリビジョン両方とも次のリビジョン
python:python_install [2020/02/02 09:17] ともやんpython:python_install [2020/02/16 13:53] – [Python 2.7/3.8 の共存] ともやん
行 49: 行 49:
 pip 20.0.2 from c:\python38\lib\site-packages\pip (python 3.8) pip 20.0.2 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>
 +
 +</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 をインストールします。
  • python/python_install.txt
  • 最終更新: 2020/09/11 16:59
  • by ともやん