Windows doesn't seem to keep my system environment variables


  1. Posts : 2
    Windows 7 64bit
       #1

    Windows doesn't seem to keep my system environment variables


    Hi all,

    As far as I can tell, my problem seems to be quite simple. The solution, however, may not be quite as simple.

    The application I am trying to make work is python 3. I also have python 2 installed, but that works fine.

    The problem is at the command prompt I would like to be able to type
    Code:
    python3
    and have it launch the python 3 shell. Currently, all I get is
    Code:
    'python3' is not recognized as an internal or external command,
    operable program or batch file.
    If I type
    Code:
    C:\Users\Jazzvibes>python
    Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    it already launches python 2 (which is correct).

    I have already tried to put python3 as a system and user environment variable, in AFAIK the same way as python is set up. I changed this at the system properties window and then going to environment variables on the "Advanced" tab.

    if I type
    Code:
    set
    at the command prompt, I believe it should confirm this (please correct me if i'm mistaken)
    Code:
    python=C:\Python26\python.exe
    python3=C:\Python31\python.exe
    So, have I done something wrong, or left a step out? Please let me know if you need more info.

    I should point out that typing a hard link to python3 using the address above does work, but I would like the shortcut for convenience (and to work out why it doesn't work in the first place)

    My system for the record is Win7 64bit. Although both python installations are 32 bit versions (although i'm fairly sure that is trivial)

    Regards,
    Jazzvibes
    Last edited by jazzvibes; 25 Jul 2010 at 23:30. Reason: clarification
      My Computer


  2. Posts : 127
    Windows 7 Ultimate x64
       #2

    I have never done anything like you are attempting to do. (Setting up an alias for an executable)

    I would tackle the problem by creating .cmd or .bat files that are in the path that then calls the proper executable and passes along all parameters.

    For example, your batch file for python 3 would be called python3.bat (captain obvious to the rescue ) and you would include the following code:

    Code:
     
    C:\Python31\python.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
    I'm not sure you need to include all of those command line parameter pass-throughs but it can't hurt.
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Add C:\Python31 to the end of the existing path environment variable. You do this by adding a ; (semi colon) then the path to C:\Python31. That will make it accessible from a Command Prompt.
      My Computer


  4. Posts : 3,371
    W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
       #4

    In order to access your environment variable from the command line you need to bracket it with % like this: %python3%. In order to use the environment variable in a batch file you need to bracket it with %% like this: %%python3%%
      My Computer


  5. Posts : 2
    Windows 7 64bit
    Thread Starter
       #5

    Woah thanks! Some good working solutions.
    ZTruker has suggested the one that is most like the original though. I looked in the path variable to find C:\Python26, and added C:\Python31 and now it works exactly as expected.

    the batch file method and the %python3% method both worked well too.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:47.
Find Us