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

Add System Path?!?

P: n/a
Hello NG,

I have a GUI (written in wxPython) that calls some external exe files..
Some of them requires that I add to the PATH variable 1 directory. Basically,
the exe are located in:

/MyApp/Solvers/FirstExe
/MyApp/Solvers/SecondExe

And so on, while the dll needed by these exe are located in:

/MyApp/MyDll

These exe files do not work if I don't set the PATH variable also to that
adress. I know I can do it by hand (and also my users can), but I wonder
if there is a way to do it in Python...

Thank you for all suggestions/pointers.

Andrea.
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
an***********@tin.it wrote:
These exe files do not work if I don't set the PATH variable also to that
adress. I know I can do it by hand (and also my users can), but I wonder
if there is a way to do it in Python...


You didn't mention what operating system you are using. On Unix, PATH
is an environment variable, and environment variables can be set in
a process and all child processes, but not in a parent process. So if
you can somehow arrange that the processes that need the PATH setting
are child processes of a Python interpreter, this could be possible.

If you were hoping that you invoke a Python script, and that modifies
the environments of already-running shells - that is not possible.

Regards,
Martin
Jul 18 '05 #2

P: n/a
rbt
an***********@tin.it wrote:
Hello NG,

I have a GUI (written in wxPython) that calls some external exe files.
Some of them requires that I add to the PATH variable 1 directory. Basically,
the exe are located in:

/MyApp/Solvers/FirstExe
/MyApp/Solvers/SecondExe

And so on, while the dll needed by these exe are located in:

/MyApp/MyDll

These exe files do not work if I don't set the PATH variable also to that
adress. I know I can do it by hand (and also my users can), but I wonder
if there is a way to do it in Python...

Thank you for all suggestions/pointers.

Andrea.


Check out the 'Path' value under this registry key:

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contr ol\Session
Manager\Environment"

You can import _winreg to edit it as you like. I think it's a string...
just append your path(s) to them.

rbt
Jul 18 '05 #3

P: n/a
an***********@tin.it a écrit :
Hello NG,

I have a GUI (written in wxPython) that calls some external exe files.
Some of them requires that I add to the PATH variable 1 directory. Basically,
the exe are located in:

/MyApp/Solvers/FirstExe
/MyApp/Solvers/SecondExe

And so on, while the dll needed by these exe are located in:

/MyApp/MyDll

These exe files do not work if I don't set the PATH variable also to that
adress. I know I can do it by hand (and also my users can), but I wonder
if there is a way to do it in Python...

Thank you for all suggestions/pointers.

Andrea.

Why not just adding in your app

import os
os.environ['PATH'] += ";the_new_adress_needed_by_exe"

this will just modify locally to your app the environement variable PATH

If you want to modify it for ever, just open a console DOS (cmd.exe) and
type:
set PATH=%PATH%;the_new_adress_needed_by_exe

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.