Add System Path?!?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrea_gavana@tin.it

    #1

    Add System Path?!?

    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.


  • Martin v. Löwis

    #2
    Re: Add System Path?!?

    andrea_gavana@t in.it wrote:[color=blue]
    > 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...[/color]

    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

    Comment

    • rbt

      #3
      Re: Add System Path?!?

      andrea_gavana@t in.it wrote:[color=blue]
      > 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.
      >
      >[/color]

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

      "HKEY_LOCAL_MAC HINE\SYSTEM\Cur rentControlSet\ Control\Session
      Manager\Environ ment"

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

      rbt

      Comment

      • Fouff

        #4
        Re: Add System Path?!?

        andrea_gavana@t in.it a écrit :[color=blue]
        > 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.
        >
        >[/color]
        Why not just adding in your app

        import os
        os.environ['PATH'] += ";the_new_adres s_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_nee ded_by_exe

        Comment

        Working...