dil_bert Posted January 28, 2018 Share Posted January 28, 2018 How do I tell a Python script to use a particular version? How do I, in the main.py module (presumably), tell Python which interpreter to use?What I mean is: if I want a particular script to use version 2 of Python to interpret the entire program, how do I do that?I know that you can run your programs/scripts with different versions by typing "Py -2 file.py" or "Py -3 file.py", but is there any way to run... btw if i do so - it fails py -2 cp1.py martin@linux-3645:~/_dev_/python> py -2 cp1.py If 'py' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf py martin@linux-3645:~/_dev_/python> Quote Link to comment https://forums.phpfreaks.com/topic/306350-how-do-i-tell-a-python-script-to-use-a-particular-version/ Share on other sites More sharing options...
requinix Posted January 28, 2018 Share Posted January 28, 2018 The script itself can't decide that. You either have to run the file with the right python version, or turn the file into a shell executable (chmod +x) with a shebang of one of #!/usr/bin/env python2 #!/usr/bin/env python3 Quote Link to comment https://forums.phpfreaks.com/topic/306350-how-do-i-tell-a-python-script-to-use-a-particular-version/#findComment-1555824 Share on other sites More sharing options...
dil_bert Posted January 30, 2018 Author Share Posted January 30, 2018 hello dear requinix, many thanks for the quick answer. I tried it out. And yes: it works fine now. Thanks for this help - it enables me to go further - and ahead with a certain project. Greetings Quote Link to comment https://forums.phpfreaks.com/topic/306350-how-do-i-tell-a-python-script-to-use-a-particular-version/#findComment-1555882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.