1
1

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

背景

  • 趣味用のスクレイピングツール作成時、Playwrightの非同期処理を実行するためにPyhon3.11.x が必要らしい
  • Python 3.11.x を用いて仮想環境を作成しようとしたらエラー(下記)
PS C:\hoge> py -3.11 -m venv myenv 
No suitable Python runtime found
Pass --list (-0) to see all detected environments on your machine
or set environment variable PYLAUNCHER_ALLOW_INSTALL to use winget
or open the Microsoft Store to the requested version.
  • py --listを実行したところ、Python 3.12.x3.10.x しかなかった(下記)
PS C:\hoge> py --list
 -V:3.12 *        Python 3.12 (64-bit)
 -V:3.10          Python 3.10 (64-bit)

方法

  • Python公式サイトから Python 3.11.x のインストーラーをDLしてインストール
    • ※起動時に Add Python.exe to PATH チェックボックスをオンにすること
PS C:\hoge> py --list
 -V:3.12 *        Python 3.12 (64-bit)
 -V:3.11          Python 3.11 (64-bit)
 -V:3.10          Python 3.10 (64-bit)

仮想環境作成

  • 下記手順でOK
PS C:\hoge> py -3.11 -m venv myenv
PS C:\hoge> .\myenv\Scripts\Activate.ps1
(myenv) PS C:\hoge> python --version
Python 3.11.9
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?