LoginSignup
2
1

More than 3 years have passed since last update.

現在実行中のpython.exeのパスを取得するには

Last updated at Posted at 2021-01-16

現在、当スクリプト.pyファイルを実行中のpython.exeのパスを取得するには: sys.base_prefix

Console
import sys
sys.base_prefix
結果
'C:\\python-3.7.4.amd64'


P.S.

一方、Pythonで実行中の当スクリプト.pyファイルのパスを取得するには: __file__

test.py
print(__file__)
結果
'C:\\test.py'
2
1
2

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
2
1