0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonの複数バージョンをWindowsで使う設定(自己メモ)

Posted at

Pythonの複数バージョンをWindowsで使う設定

Windows PCでPythonの複数バージョンを使う設定をよく忘れるので備忘録に。

1.Pythonのインストール

・Pythonの必要なバージョンをインストール
 私の例 2.7 3.9 最新(現時点で3.13)
・インストールプログラムのダウンロード先
 https://www.python.org/downloads/windows/
・インストールはデフォルトで行わない
 私の例 C:\Python に各バージョンをインストール

2.インストール結果を試す

C:\work\python>py --list
 -V:3.13 *        Python 3.13 (64-bit)
 -V:3.9           Python 3.9 (64-bit)
 -V:2.7           Python 2.7

C:\work\python>py -V
Python 3.13.6

C:\work\python>py -3.9 -V
Python 3.9.13

C:\work\python>py -2.7 -V
Python 2.7.18

3.バージョン依存環境を作成、試験する

rem 現在の環境を確認
C:\work\python>py -V
Python 3.13.6

C:\work\python>py -m pip -V
pip 25.2 from C:\python\Python313\Lib\site-packages\pip (python 3.13)

rem 3.9バージョン依存プロジェクト作成
C:\work\python>py -3.9 -m venv test

rem プロジェクト適用
C:\work\python>test\Scripts\activate.bat   

(test) C:\work\python>py -V
Python 3.9.13

(test) C:\work\python>pip -V
pip 22.0.4 from C:\work\python\test\lib\site-packages\pip (python 3.9)

rem プロジェクト開放
(test) C:\work\python>test\Scripts\deactivate.bat

rem 環境が戻ったか確認
C:\work\python>py -V
Python 3.13.6

C:\work\python>py -m pip -V
pip 25.2 from C:\python\Python313\Lib\site-packages\pip (python 3.13)

参考サイト

・Windows で複数バージョンの Python を使う(@landwarrior さん)
https://qiita.com/landwarrior/items/1b5e0f9af5316a025fe0
・windows環境にてpythonのバージョンを指定してvenvを作成する(@UT_ITDaiku さん)
https://qiita.com/UT_ITDaiku/items/4af9c7a1b9a91b98935f

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?