0

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
    That seems to be the definition of sys.executable. Perhaps you want to look in sys.argv[0] ? – meuh Nov 18 '18 at 19:18
0

Found the solution myself:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.