473,238 Members | 2,834 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,238 software developers and data experts.

Adding Python to the path in Windows

I have many users using two different versions of python, 2.4 and
2.5. I am running Python scripts on their computers programmatically,
but I can't run it with the full path because they have different
versions installed. I need to run it like 'python {script name}'. So
I need to add Python to the path. How do I do this permanently
without going to each computer and setting it through the GUI? I
tried creating a Windows batch script using setx, but the user had to
be an administrator.

Or is there any other way I can run whatever version of Python happens
to be installed with a single command? Anyone have any ideas? Such a
simple issue, there must be a simple solution. (of course, this is
Windows).

Thanks for any help.

Jun 21 '07 #1
9 2407
ky**@thenortheastgroup.com wrote:
I have many users using two different versions of python, 2.4 and
2.5. I am running Python scripts on their computers programmatically,
but I can't run it with the full path because they have different
versions installed. I need to run it like 'python {script name}'. So
I need to add Python to the path. How do I do this permanently
without going to each computer and setting it through the GUI? I
tried creating a Windows batch script using setx, but the user had to
be an administrator.

Or is there any other way I can run whatever version of Python happens
to be installed with a single command? Anyone have any ideas? Such a
simple issue, there must be a simple solution. (of course, this is
Windows).
Assuming they have Python installed normally there will be file
associations set up for .py and .pyw, so all you need to do to type in
the script name: Python itself does not need to be in the path.
N.B. You do need to include the .py extension unless you can arrange to
edit the PATHEXT environment variable.

e.g.

C:\Temp>type t.py
import sys
print sys.version

C:\Temp>t.py
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]

C:\Temp>assoc .py
..py=Python.File

C:\Temp>ftype Python.File
Python.File="C:\Python25\python.exe" "%1" %*

Jun 21 '07 #2
On Jun 21, 10:10 am, Duncan Booth <duncan.bo...@invalid.invalid>
wrote:
k...@thenortheastgroup.com wrote:
I have many users using two different versions of python, 2.4 and
2.5. I am running Python scripts on their computers programmatically,
but I can't run it with the full path because they have different
versions installed. I need to run it like 'python {script name}'. So
I need to add Python to the path. How do I do this permanently
without going to each computer and setting it through the GUI? I
tried creating a Windows batch script using setx, but the user had to
be an administrator.
Or is there any other way I can run whatever version of Python happens
to be installed with a single command? Anyone have any ideas? Such a
simple issue, there must be a simple solution. (of course, this is
Windows).

Assuming they have Python installed normally there will be file
associations set up for .py and .pyw, so all you need to do to type in
the script name: Python itself does not need to be in the path.
N.B. You do need to include the .py extension unless you can arrange to
edit the PATHEXT environment variable.

e.g.

C:\Temp>type t.py
import sys
print sys.version

C:\Temp>t.py
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]

C:\Temp>assoc .py
.py=Python.File

C:\Temp>ftype Python.File
Python.File="C:\Python25\python.exe" "%1" %*
If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.

Mike

Jun 21 '07 #3
On Jun 21, 11:10 am, Duncan Booth <duncan.bo...@invalid.invalid>
wrote:
Assuming they have Python installed normally there will be file
associations set up for .py and .pyw, so all you need to do to type in
the script name: Python itself does not need to be in the path.
N.B. You do need to include the .py extension unless you can arrange to
edit the PATHEXT environment variable.

e.g.

C:\Temp>type t.py
import sys
print sys.version

C:\Temp>t.py
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]

C:\Temp>assoc .py
.py=Python.File

C:\Temp>ftype Python.File
Python.File="C:\Python25\python.exe" "%1" %*
Wow, I knew there must be a simple solution, but I didn't know it was
that simple. I feel sort of dumb now! But thanks a lot, that saved
me a lot of work.
Jun 21 '07 #4
On Jun 21, 11:22 am, kyoso...@gmail.com wrote:
>
If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.

Mike
Mike,

I place the scripts on the server, but hadn't thought of placing an
entire Python installation on the server. I just tried it and it
seems to work. It shouldn't cause any problems? That might actually
work out really well too. Thanks for the suggestion.

Jun 21 '07 #5
On Jun 21, 10:30 am, k...@thenortheastgroup.com wrote:
On Jun 21, 11:22 am, kyoso...@gmail.com wrote:
If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.
Mike

Mike,

I place the scripts on the server, but hadn't thought of placing an
entire Python installation on the server. I just tried it and it
seems to work. It shouldn't cause any problems? That might actually
work out really well too. Thanks for the suggestion.
We've been running python scripts over the network for more than a
year. The only issues I can think of is that at first it didn't always
find that weird Python dll file, but once we got that on the server,
that problem went away too.

Mike

Jun 21 '07 #6
On Jun 21, 10:45 am, kyoso...@gmail.com wrote:
On Jun 21, 10:30 am, k...@thenortheastgroup.com wrote:
On Jun 21, 11:22 am, kyoso...@gmail.com wrote:
If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.
Mike
Mike,
I place the scripts on the server, but hadn't thought of placing an
entire Python installation on the server. I just tried it and it
seems to work. It shouldn't cause any problems? That might actually
work out really well too. Thanks for the suggestion.

We've been running python scripts over the network for more than a
year. The only issues I can think of is that at first it didn't always
find that weird Python dll file, but once we got that on the server,
that problem went away too.

Mike
I should probably mention that if you have some complicated GUI's,
they will probably load slowly over the network. And I did notice that
scripts using WMI and pyWin32 modules can be slower than they ought to
be. Just something to keep in mind if you have a slow connection. We
have a T1 out to a remote location and it's caused some minor issues
using anything of that nature.

Mike

Jun 21 '07 #7
ky******@gmail.com wrote:
On Jun 21, 10:10 am, Duncan Booth <duncan.bo...@invalid.invalid>
wrote:
>k...@thenortheastgroup.com wrote:
>>I have many users using two different versions of python, 2.4 and
2.5. I am running Python scripts on their computers programmatically,
but I can't run it with the full path because they have different
versions installed. I need to run it like 'python {script name}'. So
I need to add Python to the path. How do I do this permanently
without going to each computer and setting it through the GUI? I
tried creating a Windows batch script using setx, but the user had to
be an administrator.
Or is there any other way I can run whatever version of Python happens
to be installed with a single command? Anyone have any ideas? Such a
simple issue, there must be a simple solution. (of course, this is
Windows).
Assuming they have Python installed normally there will be file
associations set up for .py and .pyw, so all you need to do to type in
the script name: Python itself does not need to be in the path.
N.B. You do need to include the .py extension unless you can arrange to
edit the PATHEXT environment variable.

e.g.

C:\Temp>type t.py
import sys
print sys.version

C:\Temp>t.py
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]

C:\Temp>assoc .py
.py=Python.File

C:\Temp>ftype Python.File
Python.File="C:\Python25\python.exe" "%1" %*

If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.

Mike
Another solution is to use py2exe to convert your python program into an .exe
file that you can distribute. Then they require no Python installation at all.
I use py2exe and Inno Installer to do just that and it works great.

-Larry
Jun 21 '07 #8
On Jun 21, 11:49 am, kyoso...@gmail.com wrote:
I should probably mention that if you have some complicated GUI's,
they will probably load slowly over the network. And I did notice that
scripts using WMI and pyWin32 modules can be slower than they ought to
be. Just something to keep in mind if you have a slow connection. We
have a T1 out to a remote location and it's caused some minor issues
using anything of that nature.

Mike
I will probably do this then, because Duncan's solution does not seem
to be working for me. If I run a Python script directly from a
command line, it works fine just like he said. But I am using the
Shell() command in Visual Basic 2005 to run the Python script, and it
doesn't seem to be working. I am getting an error, "File not found".
Not sure what the difference would be. But your solution should work.

Jun 21 '07 #9
On Jun 21, 11:53 am, Larry Bates <larry.ba...@websafe.comwrote:
Another solution is to use py2exe to convert your python program into an .exe
file that you can distribute. Then they require no Python installation at all.
I use py2exe and Inno Installer to do just that and it works great.

-Larry
Yeah, I didn't even think of that. The server install of Python seems
like the best option for my situation though. Thanks for all the
great suggestions.
Jun 21 '07 #10

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

Similar topics

2
by: WIWA | last post by:
I'm looking for SNMP support in Python. I have found pySNMP, but I'm not sure whether this works under Windows as well. A few questions: 1) Where do I need to install the pySNMP files? 2) What...
20
by: BJ MacNevin | last post by:
Hi all, I teach middle school and am currently trying to bring some computer science to the students. Our district has a wonderfully linked network throughout all our schools... done via MS...
23
by: Spiffy | last post by:
hello, i'm fairly new to python programming and programming in general, but i have written a python prog that creates a MIDI file (.mid) and I want to be able to play it from another prog which is...
2
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package...
9
by: Amir Dekel | last post by:
Hi everyone, I have two problems: 1. How can I keep my changes in sys.path after closing the interpreter? 2. os.path.expanduser("~") always gives me "C:\\" instead of my homepath. I have...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
21
by: Hitesh | last post by:
Hi, I get path strings from a DB like: \\serverName\C:\FolderName1\FolderName2\example.exe I am writing a script that can give me access to that exe file. But problem is that string is not...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH...
3
by: redefined.horizons | last post by:
I have been trying to find a way to add a directory to Python's sytem path on my MS Windows XP computer. I did some searching online, but the only solution I found involved editing the MS Windows...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.