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> Link to comment 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 Link to comment 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.