0

I have my script written in python3, but when I share the script with other users and the user has python2 environment my script won't run. Is there a way to make my py3 script run regardless of what python environment the user has? is there a way to unset their current python and set to python3(assuming I know the py3 location)?.

If I have a bash wrapper, I can export both PYTHON and PYTHONPATH variables but not sure how to do this in python. Thanks.

Gopinath S
  • 511
  • 6
  • 20
  • 3
    Make a standalone executable from the Python script so you don't need them to have anything. – jarmod Oct 10 '18 at 16:24
  • 1
    I think people will be pretty unhappy with you if you start changing their path just to run your script. – mypetlion Oct 10 '18 at 16:34
  • Possible duplicate of [Python 2 and Python 3 dual development](https://stackoverflow.com/questions/11372190/python-2-and-python-3-dual-development) – r.ook Oct 10 '18 at 16:36
  • This sounds like a job for virtual environments (often with [virtualenv](https://virtualenv.pypa.io/en/stable/) or [pipenv](https://github.com/pypa/pipenv)), which are a/the sane way to handle sandboxing Python. If you can't give them a shell script to run, though, you may be out of luck; without more details on your target users and your requirements, we can't really tell. – kungphu Oct 11 '18 at 05:17

0 Answers0