Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:56:16+00:00 2026-06-07T01:56:16+00:00

I have this problem: System A runs Ubuntu and needs Python 2.6 for a

  • 0

I have this problem:

System A runs Ubuntu and needs Python 2.6 for a bunch of different things.
I Installed Python 2.7 separately on System A
System B has Python 2.7 natively.

I have a python script BLAH which says #!/bin/env python up top.
Further down it executes another script SIGH, which up top also says: #!/bin/env python.

BLAH needs to run on either System A or System B, and it always needs to run Python 2.7

—-
Part of my solution so far:
Have a wrapper script that first tries to see if which python is pointing to Python 2.7
If that’s okay then run BLAH with that path for python.
Else try which python2.7 and use that path to run BLAH , and add that path to env PATH.

Problem with this solution is:

On System A (which has Python 2.7 installed separately)
When BLAH executes, it runs with Python 2.7 because of the wrapper script I wrote (okay so far..)
When BLAH spawns SIGH, SIGH uses the shebang to find python in the path and then it’s in trouble because it’s looking for python in env‘s PATH and it should be looking for python2.7 in the path.

Is there a clean way of handling this problem?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:56:18+00:00Added an answer on June 7, 2026 at 1:56 am

    If you have a script that needs a certain python version, for example 2.7, I’d change the first line to

    #!/bin/env python2.7
    

    And then ensure that python2.7 is on your path (you may have to add symlinks as appropriate). In all the distributions I’ve used, these symlinks already exist.

    (In fact, python is typically a symlink to pythonX which is a symlink to pythonX.Y or, in my case, python -> python2 -> python2.7. )

    There’s no need to hard-code a full path, as this may vary from distro to distro or box to box.

    But since there should be no ambiguity for an executable on your path named python2.7, you should be fine without having to worry about hard-coding paths.

    Alternatively, from within the first script, you could call the python interpreter directly, as in:

    subprocess.Popen(['pythonX.Y', SCRIPT_NAME])
    

    instead of

    subprocess.Popen([SCRIPT_NAME])
    

    EDIT As J.F. Sebastian notes in the comments, you could use sys.executable in the first argument to ensure that the second script was passed to the same interpreter as the first. e.g

    subprocess.Popen([sys.executable, SCRIPT_NAME])
    

    As a side note, that may or may not be useful, you can access the version of the “current” Python interpreter inside the script by

    import sys
    print(sys.hexversion)
    

    which may be useful to determine whether the correct interpreter is running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem: I want to generate a new source code file from
I have this problem: $id is id for each user $img = 'http://www.somesite.com/pictures/'; $no_img
I have this problem since I'm beginning in OOP programming I want to close
I have this problem when I run SAS 9.2 on the command line on
I have this problem, when I load my form, the validation messages appears in
I have this problem in my SlashDot Menu. I want to change the picture
I have this problem that I can ref a button for control it. I
I have this problem having to display my jasper report on my grails application.
I have this problem where I open Visual Studio and the internal windows are
i have this problem to find a particular xml node l have post this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.