By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,499 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

Adding Python to the path in Windows

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.