1

I need to run Python interpreter with custom parameters and custom environment.

Let's say I create a bash script which exports required variables and calls /usr/bin/python3 with required parameters. When I run Python via this script, sys.executable will be still /usr/bin/python3.

Can I somehow construct the wrapper script such that sys.executable would report the path of the wrapper script? I tried exec /usr/bin/python3, but this didn't change the matters.

1
  • 1
    That seems to be the definition of sys.executable. Perhaps you want to look in sys.argv[0] ?
    – meuh
    CommentedNov 18, 2018 at 19:18

1 Answer 1

1

Found the solution myself:

exec -a "$0" /usr/bin/python3

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.