Running python from a usb drive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cjl

    #16
    Re: Running python from a usb drive

    Jason:

    Thanks! That worked...in fact, almost everything is now working as
    expected (so far).

    Here is my batch file:

    echo "Making changes to path and file associations... "
    path =
    %PATH%;%CD%Pyth on24;%CD%Python 24\libs;%CD%Pyt hon24\Scripts;% CD%Python24\Lib \site-packages;%CD%Py thon24\DLLs
    set PYTHONPATH=%CD% Python24
    ASSOC .py=Python.File
    ASSOC .pyc=Python.Com piledFile
    ASSOC .pyo=Python.Com piledFile
    ASSOC .pyw=Python.NoC onFile
    FTYPE Python.File=%CD %Python24\pytho n.exe "%%1" %%*
    FTYPE Python.Compiled File=%CD%Python 24\python.exe "%%1" %%*
    FTYPE Python.NoConFil e=%CD%Python24\ pythonw.exe "%%1" %%*
    set PATHTEXT=.py;%P ATHTEXT%
    CMD

    I'm still having a problem with setting PATHTEXT...I should be able to
    now type django-admin at the cmd prompt and have it work, but I need to
    still type django-admin.py ... I'm not sure what's wrong with my
    setting of pathtext.

    Any ideas?

    Thanks again,
    CJL

    Comment

    • Thorsten Kampe

      #17
      Re: Running python from a usb drive

      * cjl (2006-09-12 13:10 +0100)
      Jason:
      >
      Thanks! That worked...in fact, almost everything is now working as
      expected (so far).
      >
      Here is my batch file:
      >
      echo "Making changes to path and file associations... "
      path =
      %PATH%;%CD%Pyth on24;%CD%Python 24\libs;%CD%Pyt hon24\Scripts;% CD%Python24\Lib \site-packages;%CD%Py thon24\DLLs
      set PYTHONPATH=%CD% Python24
      ASSOC .py=Python.File
      ASSOC .pyc=Python.Com piledFile
      ASSOC .pyo=Python.Com piledFile
      ASSOC .pyw=Python.NoC onFile
      FTYPE Python.File=%CD %Python24\pytho n.exe "%%1" %%*
      FTYPE Python.Compiled File=%CD%Python 24\python.exe "%%1" %%*
      FTYPE Python.NoConFil e=%CD%Python24\ pythonw.exe "%%1" %%*
      set PATHTEXT=.py;%P ATHTEXT%
      CMD
      >
      I'm still having a problem with setting PATHTEXT...I should be able to
      now type django-admin at the cmd prompt and have it work, but I need to
      still type django-admin.py ... I'm not sure what's wrong with my
      setting of pathtext.
      Setting environment variables has only effect on the process itself
      and the subprocesses. This has nothing to do with Windows, it's the
      same with Linux.

      Comment

      • cjl

        #18
        Re: Running python from a usb drive

        Thorsten:

        Thank you for your reply.
        Setting environment variables has only effect on the process itself
        and the subprocesses. This has nothing to do with Windows, it's the
        same with Linux.
        True, and the changes to path and pythonpath are gone after I close the
        console window, but the results of the assoc and ftype commands are
        changes to the registry that linger. If I run my setup on a computer
        that has python installed, I will overwrite the pre-existing registry
        settings. I can restore them with a script, but I can't guarantee that
        my restore script will run.

        I'm still looking for a way to modify these temporarily, but it looks
        like I might be "up the creek" on this one. Oh well.

        Thanks again,
        CJL

        Comment

        • Jason

          #19
          Re: Running python from a usb drive

          cjl wrote:
          Thorsten:
          >
          Thank you for your reply.
          >
          Setting environment variables has only effect on the process itself
          and the subprocesses. This has nothing to do with Windows, it's the
          same with Linux.
          >
          True, and the changes to path and pythonpath are gone after I close the
          console window, but the results of the assoc and ftype commands are
          changes to the registry that linger. If I run my setup on a computer
          that has python installed, I will overwrite the pre-existing registry
          settings. I can restore them with a script, but I can't guarantee that
          my restore script will run.
          >
          I'm still looking for a way to modify these temporarily, but it looks
          like I might be "up the creek" on this one. Oh well.
          >
          Thanks again,
          CJL
          I notice that you've already got the environmental variables set up to
          run your Temp-Python. You can retrieve the current associations (if
          any) by using the assoc and ftype commands:

          C:\>assoc .py
          ..py=Python.Fil e

          C:\>ftype Python.File
          Python.File="C: \Python24\pytho n.exe" "%1" %*

          C:\>assoc .NotAnExtension
          File association not found for extension .NotAnExtension

          C:\>

          Using this information, you could write a little python script with
          your distribution which records the current file associations and
          settings. Then, when you're ready to revert, you run another little
          python script which restores the associations.

          These associations are also stored in the registry. You could back up
          the registry keys which you know will be modified, make the registry
          changes yourself, and restore the registry settings at finish. It
          would require Python's win32 extension modules, though.

          I don't know how you could do it without using a
          backup/run-stuff/restore sequence.

          --Jason

          Comment

          Working...