473,410 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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.py"

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 2759
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.py"

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\WStools\WSsend.exe"
Start in: "C:\Program Files\WebSafe\WStools\"

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.comwrote:
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\WStools\WSsend.exe"
Start in: "C:\Program Files\WebSafe\WStools\"

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.py 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
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...
13
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...
0
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...
15
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...
17
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...
1
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...
1
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...
8
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. ...
6
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.