3
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?

More than 1 year has passed since last update.

[Windows×Python] バッチファイルで仮想環境をアクティベートしてPythonファイルを実行する

Posted at

試したこと

以下では、仮想環境をアクティベートした時点でコマンド実行が終了しています。

python.bat

cd "パス"
venv\Scripts\activate
python "パス\python_file.py"

解決策

callを使って仮想環境をアクティベートする

python.bat

cd "パス"
call venv\Scripts\activate
python "パス\python_file.py"

これで、コマンドプロンプトを開いて、1ライナーでPythonファイルを実行できます!

実行例

python.bat

参考

3
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
3
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?