Add System Path?!?

A

andrea_gavana

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.
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

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
 
R

rbt

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\Control\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
 
F

Fouff

(e-mail address removed) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,234
Messages
2,571,178
Members
47,810
Latest member
Quinn16P02

Latest Threads

Top