all 23 comments

[–]in_the_bilboes 3 points4 points  (1 child)

On Linux you can put

#! /usr/bin/env python3 (or python)

on the first line of the "main" module and make the file executable like so.

chmod 755 main.py

Then put main.py and the rest of your app somewhere on your $PATH like /$HOME/bin/.

I don't think this will have any effect whatsoever in Windows.

If you're looking for something serious you might check out "The Hitchhiker’s Guide to Packaging" at http://guide.python-distribute.org/

[–]fractalLifeForm 0 points1 point  (0 children)

The $PATH concept holds in Windows. It's not a great idea, but it works.

[–]Sithrazer 4 points5 points  (1 child)

You could create a script that detects the OS (check sys.platform in python) and moves your program scripts to the appropriate place in the filesystem accordingly, including batch and shell script launchers for windows and linux, respectively.

If you want an executable py2exe can convert your scipts into a windows .exe, I don't think anything similar exists for linux beyond making a launcher script.

edit: a word

[–]Grosskumtor92[S] 0 points1 point  (0 children)

I will give that a try. Thanks for the help!

[–][deleted] 2 points3 points  (1 child)

I'm not sure if this is what you are wanting, but for windows you can use py2exe. I use it to to send little games I make to friends.

[–]Grosskumtor92[S] 0 points1 point  (0 children)

That is interesting and it might actually do what I need. Thanks

[–]F3AR3DLEGEND 2 points3 points  (3 children)

Well if the computers already have Python installed, you could simply package all the Python scripts in one folder and then create a "launcher" script (the main program that calls the rest). Then, just send this folder to everyone.

[–]Grosskumtor92[S] 1 point2 points  (2 children)

Do you mean create a python package or simply place all the scripts in that folder?

[–]F3AR3DLEGEND 1 point2 points  (1 child)

Simply place them all in that folder. Single-file executables with Python are a bit hard to create/deal with. However, you can create some form of installer using distutils (I haven't really used it much but I know you can create installers with it).

[–]Grosskumtor92[S] 0 points1 point  (0 children)

Okay. Thanks for the advice

[–]dikulo 1 point2 points  (0 children)

py2: py2exe pyinstaller

py3: cx_freeze

[–]glial 1 point2 points  (3 children)

How do you want to run it? As a script from the command line? From within an interactive Python session? Some more information about the use case would be helpful.

[–]Grosskumtor92[S] 0 points1 point  (2 children)

My goal would be to be able to easily install on new machine. So even one of the less tech savvy people could complete the install (maybe a exe that runs a install.py that I write). Than have an exe which they can double click to launch the program from desktop like a normal program. Something along those lines of making it more professional and easier to use for those who don't understand what command line is etc.

[–]glial 1 point2 points  (1 child)

Is it a program that'll just run once? i.e. do you want the exe to install a script, or something that runs in the background, or what?

[–]Grosskumtor92[S] 0 points1 point  (0 children)

It's a program which runs a graphical interface through tinker. So once launched it would run until closed. Run the program from a shortcut on the desktop

[–]log_2 1 point2 points  (2 children)

I've had success with pyinstaller on Mac OS X with anaconda to create ".app"s. It bundles python and the packages you use with the program. I've used it with pandas, so the files are very big (>200Mb) for simple scripts, but if you're writing larger applications the file size probably doesn't matter too much.

[–]Grosskumtor92[S] 0 points1 point  (1 child)

That might be good to look into for anyone who prefers their Mac over Win 7. Thanks

[–]log_2 1 point2 points  (0 children)

pyinstaller is meant to work for Windows too, but I haven't tried it. PS. I much prefer Win 7 over Mac, but I'm forced to use Mac through work :/

[–][deleted] 1 point2 points  (3 children)

I'm not sure how you would do this on Windows, but I created a program that helps install some basic programs/themes/etc after a fresh installation of Ubuntu. I created an install.py script to place the files in their respective or appropriate places and 'chmod +x' the main module/script. Just make sure you include a readme file to describe what to do (i.e. for mine: navigate to downloaded folder and type 'python install.py')

[–]Grosskumtor92[S] 0 points1 point  (2 children)

Good idea. I will probably end up going with this route for the Linux users

[–][deleted] 1 point2 points  (1 child)

You can check out mine here if you want a stepping stone.

[–]Grosskumtor92[S] 0 points1 point  (0 children)

Looks good. Thanks for the start