简体   繁体   中英

How can I write a command for linux machine to find out python path

I want to create a python program which on running gives me the python path in the linux environmental variable. In windows I am doing below way -

import os
try:
    user_paths=os.environmen['path'].split(os.pathstep)
excepterror:
    user_paths=[]
print(user_paths)

Similar answer here: https://stackoverflow.com/a/2589722/6317430

Using the sys package:

import sys
print(sys.executable)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM