Having my Python package install shortcuts in Start menu - python

I'm making a Python package that gets installed with a setup.py file using setuptools.
The package includes a GUI, and when it's installed on a Windows machine, I want the installation to make a folder in "Programs" in the start menu, and make a shortcut there to a pyw script that will start the GUI. (The pyw think works on all platforms, right?)
On Mac and Linux, I would like it to put this shortcut in whatever Mac and Linux have that is parallel to the start menu.
How do I do this?

Linux systems typically do not use a .pyw extension for executable applications (though you could if you wish). Traditionally, a python (or perl, bash, etc) script on Linux has no file name extension, has execution permissions, and begins with the 'magic' line "#!/usr/bin/python'. The '#!' lets the OS know that this is a script requiring an interpreter and the following path denotes the interpreter to use.
As for adding the desktop shortcut, freedesktop.org hosts the specifications for how menus work for modern Linux desktops. Specifically, the one you'll be most interested in is the one for Desktop Entries though the one on Menu Generation may also be of interest.

InnoSetup allows you to create shorcuts in the windows start menu. You can add even an uninstall icon.
The relevant sections of the innosetup file are:
UninstallDisplayIcon={app}\myico.ico
[Icons]
Name: "{group}\MyPrograms"; Filename: "{app}\miexe.exe" ;WorkingDir: "{app}"; Comment: "miexe program"
for Mac and Linux I can not help

Take a look at how the post-install script for pywin32 does it (search for shortcut). Not sure about Mac/Linux.

Since setuptools doesn't seem to give an easy solution to this, I've decided to give up on this idea until I release my app with py2exe/InnoSetup.

For windows, conda uses menuinst https://github.com/ContinuumIO/menuinst

Related

Python files to an MSI Windows installer

So I can use PyInstaller to make a one-file executable and to make a standard executable among other files in a folder.
But how do I turn Python files into an MSI installer so that it's fool-proof where it makes a shortcut on the desktop? (For distribution so that it isn't required for the user to have Python installed)
(When I say Python files to an MSI installer I mean the regular PyInstaller to folder output but with a way of getting a shortcut to the executable onto the desktop very easily for a regular user)
(It doesn't have to be PyInstaller if there's an alternative).
Pyinstaller does not intergrate such a tool.
You could get a third party installer (some suggested here How to create a robust, minimal installer for Windows?) and add your output exe to it and install that way, if you choose the right tool you will be able to add to desktop (plus a lot of other actions such as adding to path ect).
Or you could use cx_Freeze which has it built in. When running the setup script just add the bdist_msi flag.
It can add to shortcut desktop but is fairly limited in other ways (or you may need to perform some hack).
To add to desktop with cx_Freeze see Use cx-freeze to create an msi that adds a shortcut to the desktop.
You can use Inno which creates a shortcut on the desktop and start menu. Also, it is located in the program directory of windows. it means that you can install/uninstall it like other programs or applications.
Inno website:
https://www.jrsoftware.org/isinfo.php
A tutorial on how to use it on youtube:
https://www.youtube.com/watch?v=DTQ-atboQiI

Simplest way for end users to run Python script on network drive without installation?

I want to start using Python at work, and I have a script that I need all the end users to run on a central network drive.
However, they don't have admin rights to install Python and I am not going to call desktop support and go through that mess. I'm thinking of putting my WinPython installation on the network, pointing to the py.exe in a BAT file, and instruct users to run the BAT file.
Is there a better way to do this?
I ended up using WinPython and that suited my needs nicely. It's a convenient little package.
http://winpython.sourceforge.net/
Have you tried using py2exe or Pyinstaller? Pyinstaller converts python scripts to standalone executables that can be run on windows, linux, and Mac OS.
Here's the link to their wiki page on github: https://github.com/pyinstaller/pyinstaller/wiki

What do I need to do to be able to use Panda3D from my Python text editors?

I just installed Panda3D, and I can run the example programs by double clicking them, but I can't run them from IDLE or Sublime.
I get errors like ImportError: No module named direct.showbase.ShowBase
I some people bring this up before and the responses suggested using ppython, I can't figure out how run that from Sublime, and I really the auto complete function there.
How can I either configure the Python 2.7 version that I already have to run Panda3D programs or run ppython from SUblime?
This depends on your operating system. Panda3D uses the system's python on OS X and Linux and should "just work".
For Windows Panda3D installs its own copy of Python into Panda3D's install directory (defaults to C:\Panda3D I think), and renames the executable to ppython to prevent name collisions with any other python installs you might have. In your editor you have to change which interpreter it uses to the ppython.exe in the panda3d directory.

How can I install Eclipse Indigo on Windows 7

I've downloaded Eclipse Indigo in preparation of using it to write apps in Python. There doesn’t seem to be an install file. When I double-clicked eclipse.exe the program just ran. Can I move the Eclipse directory anywhere I want it, create a shortcut and place it on my taskbar, and start writing programs?
I put the Eclipse directory in my Path statement, and tried to run it from the command line. It won’t run anywhere but in the Eclipse directory. I already have Python 3.2 installed and it does run anywhere from the command line. Will Eclipse automatically find my Python executable or do I have to do something else?
The instructions are pretty clear ... and pretty simple:
Install your JDK on Win7 (I'd choose the 64-bit JVM for 64-bit Windows, but 32-bit will work on 64-bit Windows equally well)
Unpack the "eclipse" folder from the .zip file anywhere you want. Mine happens to be in c:\eclipse.
Manually create a desktop and/or start menu link to eclipse/eclipse.exe
Here's a great reference on "PyDev":
http://www.vogella.com/articles/Python/article.html
I'd also encourage you to install the latest/greatest Eclipse ("Juno") instead of Indigo.

Install Python 3.1 on Mac OS X version 10.5.8

I use Windows. I wrote a Python 3.1 script that my Mac-using friend would like to run, but we can't get Python 3.1 to work right on his Mac. I think the problem is that the Python 3.1 framework is not being installed. Here's exactly what what I did and why I think this is the problem.
I downloaded Python 3.1.2 from the Python download page (this file). I opened the file, then opened "Python.mpkg". I proceeded with the install wizard, and I made sure to check the box to install "Shell profile updater" during the wizard. I went to "/Applications/Python 3.1" and double-clicked "Update Shell Profile.command".
Next I selected the python script I wrote and selected "File", "Get Info" in the menu bar.
Under "Open With" I selected "PythonLauncher" from "/Applications/Python 3.1". I then clicked the "Change All" button. Now I double-clicked my program to run it, but it was run by Python 2.5.1 instead of Python 3.1. (I'm sure of this, I wrote a program to "print(sys.version)".)
So now I tried to figure out why the "PythonLauncher" from "/Applications/Python 3.1" is using Python 2.5.1. I opened "PythonLauncher" and found that the interpreter for "Python Script" is "/usr/bin/pythonw". So I went to "/usr/bin/" and discovered that "pythonw" was an alias pointing to "/System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5". Obviously this should be version 3.1 instead. So I went to "/System/Library/Frameworks/Python.framework/Versions/" and discovered that the only sub-folders are "2.3" and "2.5". Where's 3.1?
Take a look at PythonBrew. It made installing Python on my Mac a lot easier.
Also this might help:
Is there a Python Equivalent of Ruby's RVM?
Python Launcher.app is a somewhat neglected app; there have been some discussion about removing it all together because it could be somewhat of a security risk if someone downloads arbitrary Python scripts from the web. It can also be kind of hit or miss if you have multiple Python versions installed. And many people just run Python from a terminal window command line so they don't need Python Launcher.app and that's probably the safest thing to do. To do so, you should first run the Update Shell Profile command in /Applications/Python 3.1 which will ensure that the proper Python framework bin directory is added to your shell path. Then you can just type:
$ python3 /path/to/script.py
That said, you can make Python Launcher work by changing the interpreter path to:
/Library/Frameworks/Python.framework/Versions/3.1/bin/python3
but I discourage you from doing so.
Another better GUI option is to launch IDLE.app and drag-and-drop files onto it in the dock or open them in its File menu.
The versions in /System/Library/Frameworks/Python.framework/... were put there as part of OS X. They should be left alone. (See this question.)
.dmg files downloaded from python.org install to /Library/Frameworks/Python.framework/.... These are user-installed, so you can install/uninstall/move however you like. These installers also created symlinks in /usr/local/bin.
You can add either /Library/.../3.1/bin or /usr/local/bin to your path in your shell if you want python3 to be on your path.

Categories