mmkw43
Posts: 699
Joined: Tue Dec 24, 2013 6:18 pm

3.4 to 3.7 -- new shebang etc?

Tue Dec 08, 2020 5:30 pm

If I have code that uses 3.4 in the shebang line or other references to 3.4 like in a subprocess call but I'm now using python3.7, do I have to change the wording from 3.4 to 3.7?
!#/usr/bin/env python3.4 or subprocess.call("sudo python3.4 script.py") ok?

I would guess it's alright but pays to ask. thanks.

User avatar
Paeryn
Posts: 3171
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: 3.4 to 3.7 -- new shebang etc?

Tue Dec 08, 2020 6:23 pm

If you specifically call it with python3.4 then yes*, you'll need to change that to python3.7 to use python3.7. Normally, unless you have a specific need to target a particular sub-version, you'd just use python3 which is usually a symlink to whichever revision you have as your main python3.

You'll need to make sure that any modules your program depends on are also installed for 3.7.

*Whilst you could make python3.4 be a symlink to python3.7 it wouldn't be advisable.
She who travels light — forgot something.
Please note that my name doesn't start with the @ character so can people please stop writing it as if it does!

klricks
Posts: 7545
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: 3.4 to 3.7 -- new shebang etc?

Tue Dec 08, 2020 6:30 pm

mmkw43 wrote:
Tue Dec 08, 2020 5:30 pm
If I have code that uses 3.4 in the shebang line or other references to 3.4 like in a subprocess call but I'm now using python3.7, do I have to change the wording from 3.4 to 3.7?
!#/usr/bin/env python3.4 or subprocess.call("sudo python3.4 script.py") ok?

I would guess it's alright but pays to ask. thanks.
As long as only one 3.x version is installed then I would just use:

Code: Select all

#!/usr/bin/env python3
python3.4 script.py won't work unless 3.4 is installed.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

Return to “Python”