473,748 Members | 9,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Small problem executing python script as shortcut

Hi all,

This is slightly OT but it drives me nuts. Whenever I create a
shortcut in the start menu (in Windows) of a python script, it will
only execute it when the path where the script resides in contains no
spaces. For example;

d:\src\app\app. py

If I drag that to the Start Menu it can be executed fine.

Whenever I distribute my app and the path will become:

"c:\program files\app\app.p y"

Windows will make spaces itself inside the shortcut so I guess it
realizes that it needs to execute the full string but probably
somewhere when resolving the app to execute the script with, the
double quotes get lost and the python interpreter (I use ActiveState
as my Python bundle) will only see "c:\program " as the first part and
doesn't pick up the latter.

I know I can write a batch script that runs the python script, but
since it is a wxPython app, I want to launch a *.pyw to suppress the
dos box. However as it seems now there is no way to create a shortcut
under windows to launch a python script when the directory contains
spaces in the name.

Does anyone know a solution? I would like to distribute my app both
with py2exe (no problems there) but also as source only version so
people can adjust the code if they wish.

Regards,
- Jorgen
Feb 7 '08 #1
2 2776
Jorgen Bodde wrote:
Hi all,

This is slightly OT but it drives me nuts. Whenever I create a
shortcut in the start menu (in Windows) of a python script, it will
only execute it when the path where the script resides in contains no
spaces. For example;

d:\src\app\app. py

If I drag that to the Start Menu it can be executed fine.

Whenever I distribute my app and the path will become:

"c:\program files\app\app.p y"

Windows will make spaces itself inside the shortcut so I guess it
realizes that it needs to execute the full string but probably
somewhere when resolving the app to execute the script with, the
double quotes get lost and the python interpreter (I use ActiveState
as my Python bundle) will only see "c:\program " as the first part and
doesn't pick up the latter.

I know I can write a batch script that runs the python script, but
since it is a wxPython app, I want to launch a *.pyw to suppress the
dos box. However as it seems now there is no way to create a shortcut
under windows to launch a python script when the directory contains
spaces in the name.

Does anyone know a solution? I would like to distribute my app both
with py2exe (no problems there) but also as source only version so
people can adjust the code if they wish.

Regards,
- Jorgen
Sure there is. Just put double quotes around the entire Target and Start in
entries in the shortcut.

Example:
Target: "C:\Program Files\WebSafe\W Stools\WSsend.e xe"
Start in: "C:\Program Files\WebSafe\W Stools\"

Suggestions:

1) Download Inno Installer and wrap your distribution into a proper installation
(setup.exe) program. It takes care of all this for you.

2) Take a look at py2exe to bundle your entire application up so that you don't
need python on the machine at all.

Hope info helps.

-Larry
Feb 7 '08 #2
Hi Larry,

Sorry for accidentally mailing you personally. I fixed the problem, it
was a problem with the search path, and once that was fixed it works
fine!

thanks again,
- Jorgen

On Feb 8, 2008 9:26 AM, Jorgen Bodde <jo************ *@gmail.comwrot e:
Hi Larry,
Sure there is. Just put double quotes around the entire Target and Start in
entries in the shortcut.

That is exacty the problem. The shortcut (if dropped on the start menu
even by hand or by Inno Installer) already has those quotes. Still, it
is mpossible to launch a python script that way so it seems.
Example:
Target: "C:\Program Files\WebSafe\W Stools\WSsend.e xe"
Start in: "C:\Program Files\WebSafe\W Stools\"

As I already explained, the windows shortcut is already formatted like that
1) Download Inno Installer and wrap your distribution into a proper installation
(setup.exe) program. It takes care of all this for you.

it's actually the same with inno setup. A python script like
c:\Program Files\app\app.p y won't start. Could you please verify this
for me? Simply make a subdir in Program Files and put a python script
in there. Then drag and drop this script as a shortcut on the start
menu. Then try to execute it. This does not seem to work
2) Take a look at py2exe to bundle your entire application up so that you don't
need python on the machine at all.

Like explained, I would like to offer both. Source based install and
exe based, so people who are into python can view the code, and
contribute if needed. I always like it when I get the choice to modify
the app when there are small issues with it that I can easly resolve.

thanks for your reply!
- Jorgen


Hope info helps.

-Larry
--
http://mail.python.org/mailman/listinfo/python-list
Feb 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
6569
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO FRICKIN' COOL!!! ***MAN*** that would save me a buttload of work and make my life sooooo much easier!" As opposed to minor differences of this feature here, that feature there. Variations on style are of no interest to me. I'm coming at this from a...
13
2281
by: Darren Dale | last post by:
Some time ago I asked about executing a python program or script. For windows, I was informed that the .py extension could be added to some list of executable extensions, and then I could just type "mycode" instead of "python mycode.py". Great advice, worked like a charm. I recently jumped ship, and have been running Gentoo Linux for about two months. Is it possible to get the same behavior on Linux? I thought it would have something to...
0
1960
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is inside a package, the invocation will fail with a "Module not found" error. This PEP is aimed at fixing that :) Cheers, Nick.
15
2609
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that for Python 2.5. Previously, posting of a draft version of the PEP to python-dev and python-list didn't actually generate any responses. I'm not sure if that's an indication that people don't see the restriction to top-level modules as a problem...
17
3875
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows XP if it makes any difference. I put a shortcut to myapp.py on the desktop and it shows up as a little green snake icon, which is really cool and Pythonic. When I double click the icon, the app launches just fine and the tkinter interface does...
1
1539
by: Iyer, Prasad C | last post by:
Hi, I am trying to create a small utility program which would be configured in registry. Something like this Windows Registry Editor Version 5.00 @="\"python C:\\workspace\\python\\Tut\\ShortCut.py\"" It gives me access denied exception when I try it.
1
3002
by: David Franit | last post by:
Hello, I am looking at tuning NUM_POOLAGENTS for many v7.x and v8.x UDB instances. Aside from logging into each instance and running 'db2 list applications', or writing a script to do so, is there any way to determine the average number of connections to an instance? Also, without getting into detailed hardware information, we have many DB2 instances on a server whose bottleneck is usually RAM/paging space as opposed to CPU. I thought...
8
4069
by: Ben Sizer | last post by:
I'd like to be able to drag a file onto a Python script in Windows Explorer, or send that file to the script via the Send To context-menu option, so I can then process that file via sys.argc. Unfortunately, I can't drag items onto the Python script, because Windows doesn't recognise that the script is executable (unless I double-click it, upon which it runs as usual, without the command line parameter of course) and won't set it as a...
6
2421
by: Fabian Braennstroem | last post by:
Hi, I am looking for a small python script, which starts a small web server with python cgi support on a linux machine. I tried: #!/usr/bin/env python import sys
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.