Archive

Posts Tagged ‘executable’

How to create an executable file from a Python script?

February 10, 2019 Leave a comment

I made a sample project with explanation. You can find it here: https://github.com/jabbalaci/PythonEXE .

I also made a YouTube video that explains everything step-by-step:

Update (20190212): this project of mine got included in PyCoder’s Weekly #355 under the title “PythonEXE: How to Create an Executable File From a Python Script?“.

Categories: python Tags: , , , ,

Equivalent of the which command in Python

March 13, 2011 Leave a comment

This entry is based on this post.

Jay’s solution:

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
Categories: python Tags: , ,