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

  • Home
  • SEARCH
  • 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 736825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:38:59+00:00 2026-05-14T07:38:59+00:00

I am trying to distribute my Python program. The program relies on version 2.6.

  • 0

I am trying to distribute my Python program. The program relies on version 2.6. I went through the distribution documentation: http://docs.python.org/distutils/index.html and what I have figured out so far is that I basically need to write a setup.py script. Something like:

setup(name='Distutils',
  version='1.0',
  description='Python Distribution Utilities',
  author='My Name',
  author_email='My Email',
  url='some URL',
  package_dir={'': 'src'},
  packages=[''],
 )

I would like to ensure that my program uses 2.6 interpreter library when user install it on their box. What would be the best approach to ensure that my program uses 2.6 ? Shall I distribute python 2.6 library along with my program ? Is there any alternative approach ?

  • 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-05-14T07:38:59+00:00Added an answer on May 14, 2026 at 7:38 am

    One option is to specify the specific version of the Python interpreter using the hash bang:

    #! /usr/bin/env python2.6
    

    Another option is to check sys.version_info, for example:

    if (sys.version_info[0] != 2) or (sys.version_info[1]<6):
        if sys.version_info[0] > 2:
            print("Version 2.6+, and not 3.0+ needed.")
            sys.exit(1)
        else:
            print "Version 2.6+, needed. Please upgrade Python."
            sys.exit(1)
    

    The hash bang is probably the best option, as it actually ensures that the script will be interpreted by “python2.6” instead of some other interpreter; however, there are some disadvantages:

    • This will only work on UNIX-like systems that use the hash bang.
    • This will won’t work if Python2.7 is installed, but not Python 2.6.

    As a workaround, what you can do is create a “launcher” Python script that checks for “python2.6″… “python2.9”, which is the last possible version of the 2.6+ line before Python 3.0+. This launcher script can then invoke your main program using whichever python interpreter it finds in the search process. You will have to make your launcher script in a way that uses elements common to most Python versions.

    Borrowing from test if executable exists in Python:

    def which(program):
        import os
        def is_exe(fpath):
            return os.path.exists(fpath) and os.access(fpath, os.X_OK)
    
        fpath, fname = os.path.split(program)
        if fpath:
            if is_exe(program):
                return program
        else:
            for path in os.environ["PATH"].split(os.pathsep):
                exe_file = os.path.join(path, program)
                if is_exe(exe_file):
                    return exe_file
    
        return None
    
    def first_which(progs):
        for prog in progs:
            progloc = which(prog)
            if progloc != None:
                return progloc
        return None
    
    def main():
        interpreter=first_which(["python2.6","python2.7","python2.8","python2.9"])
        # Invoke your program using "interpreter"
        # You will need to use os.popen or subprocess,
        # depending on the version of Python which which
        # this launcher script was invoked...
    

    My own opinion is that the method above is more complicated than necessary, and I would just go with the hash bang… or I would write out the hash bang to the Python file at deployment time, using a language other than Python (for which the version wouldn’t be an issue… otherwise, it becomes a recursive problem).

    I would also strongly urge you NOT to include a copy of Python in your software distribution. This will make your download much larger, and it will annoy users who already have a valid installation of Python available. Instead, you should simply direct users to download and install the appropriate version if it isn’t available.

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

Sidebar

Ask A Question

Stats

  • Questions 414k
  • Answers 414k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer >>> list(itertools.product(*arrays)) [(-1, -2, -3), (-1, -2, 3), (-1, 2,… May 15, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer In your case (assuming I follow correctly) your this reference… May 15, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer In c, you could use fopen, and getch. Usually, if… May 15, 2026 at 8:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.