目次
文書の過去の版を表示しています。
Python のインストール
Linux 編
殆どの Linux には既に Python が入っています。
$ python3 -V Python 3.7.4
Windows 編
- Welcome to Python.orgのDownload Python | Python.orgより最新バージョンをダウンロードしてくる。(ここでは python-3.7.4-amd64.exe を使用する。)
- ダウンロードした python-3.7.4-amd64.exe を実行して、[Customize installation] をクリックする。
- Advanced Options の [v]Install for all users にチェックを入れて Customize install location を C:\Python37 に変更する。(お好みで…)
- [Install] をクリックする。
- インストールが終わったら [Disable path length limit] をクリックしておく。
- タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。
- 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。
- システム環境変数の PATH に Python のフォルダ(C:\Python37;C:\Python37\Scripts;)を追加する。
PATH:
C:\Python37;C:\Python37\Scripts;C:\Program Files...
- コマンドラインにて動作確認を行う。
> python -V Python 3.7.4
> python -VV Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
- pip をアップグレードする。
> pip install pip -U
Collecting pip Using cached https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.0.3 Uninstalling pip-19.0.3: Successfully uninstalled pip-19.0.3
> pip -V pip 19.2.1 from c:\python37\lib\site-packages\pip (python 3.7)
Linux & Mac (pythonbrew) 編
ここでは pythonbrew を使って python をインストールします。
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