Kevin

Environmental Variable Workaround

Recommended Posts

I have created a workaround for those of you who are experiencing issues with setting up the python environmental variable. I wrote a small little program in C# that points at your python.exe and will execute python scripts or activate the python shell. Essentially, you can use this program in place of directly calling python.exe. While this is not the best solution, nor does is solve problem, it works and will let you start playing around in python instead of being frustrated.

Example:

Instead of typing

python helloworld.py

You will type

ospPython helloworld.py

(Download/Install required for this to work)

Download ospPython from gitHub: https://github.com/OneStopProgramming/ospPython

Instillation instructions included in the readme on GitHub.

Share this post


Link to post
Share on other sites

Hey Kevin, 5:30pm Sat.

I can't even start the shell to type hello world. cmd doesn't even recognize python at all .

so i deleted the 64 bit 34. I went to the python site and downloaded the x86MSI. started the set it up, when it was done, added python to the environmental tables

and THAT doesn't work either... so I'm going to delete it and try the AMD64 bit version to see if THAT works and if it doesn't

then I have no idea what to do next. just for the hell of it I also d/l'd 2.7.8 new release july 1st. I'll leave it in my folder if nothing else works.

Share this post


Link to post
Share on other sites

I deleted the 64 & d/l'd the 32 bit  ( temp if it doesn't work ) then try the 64 bit AMD  because  that's what my proc is.

this is what I get after typing python & hitting enter 

traceback <most recent call last >:file "<stdin>", line 1, in <module> name error:"python" is not defined

Share this post


Link to post
Share on other sites

Forget about using command line for a moment. Go to the directory where you installed python and double click on python.exe. If you can't find or do not remember the install directory for python use windows search and try to find python.exe. If you can't find it install it again and note the install directory.

Let me know of you have questions.

Share this post


Link to post
Share on other sites

Hello,

I read the workaround....

there's no python.exe it's an install icon in my downloads folder and will reinstall it again  - it's a windows installer program.  there is nothing else.

python didn't install in the program files folder. it's by itself in the C:\ drive right under the program files folder by itself.

I opened the python34 file in C:\ there is no osp folder to copy.

I opened EVERY folder in the python program directory. these are the folders in it: Dlls - Doc - include - lib - libs - scripts - tcl - tools 

there's 2 files : license and news. 

then there the Python application icon  which opens python shell.

then there's the pythonw application...which does nothing. then README.  this is all of them.

there's no osppython in any of the folders.

in windows32 there is no python directory folder OR ospPython folder OR in the a to z files either. mentioning python AT ALL ! 

soo.... this is an absolute mystery to me.

beats me why nothing works - I installed python on my windows 7 machine it worked fine a few weeks ago but that machine was over 7 years old and it needed to go it was having too many problems.

I had this 1 chance to get a new machine and I took it. but it had win8.1 AMD and now I'm finding out alot of prev software isn't compatible. : (

well, this all the info i have to give you (so far) I wonder if I delete the 32 bit and start over with the AMD 64 bit. it's in my downloads folder. (just in case)

the only other one I haven't tried  is the 2.7.8 - 32 bit ( I think) that was released on July 2nd.

look on python.org I d/l'd them all from there. 

Share this post


Link to post
Share on other sites

Don't delete anything!

Everything is actually working as expected. You are almost there! You got the python shell so that means that python is working and is configured correctly. ospPython is an application I wrote so you need to go and download it separately. Take the following steps and report back.

    [*]Download ospPython from gitHub. Follow this link to gitHub. https://github.com/OneStopProgramming/ospPython

    [*]On gitHub click the "Download Zip" link to download ospPython.

    [*]Extract the file and open the "ospPython Release."

    [*]You should then see two files: ospPython.exe and ospPython.exe.config.

    [*]You will need to edit ospPython.exe.config with a text editor before proceeding. Change this line "<add key="pythonPath" value="C:\Python33\python.exe" />" to "<add key="pythonPath" value="C:\Python34\python.exe" />" to match your install directory.

    [*]Copy ospPython.exe and ospPython.exe.config to your C:\Windows\System32\ folder

    [*]Open up your command prompt. (Press your windows key, type "cmd" and then hit enter)

    [*]Type "ospPython" and press enter. The python shell should then open in a new window.

    Let me know if this works for you.

Share this post


Link to post
Share on other sites

I guess I have solved the error.

 

Below is the method that i had used

 

1. Copy the python.exe file at installed location.

 for me, It was "C:\Python34"

 

2. Paste it to here -> "C:\Windows\System32"

 

This method was worked for me.

 

Those who are still having problem with environmental variable, then try it.

 

 

Share this post


Link to post
Share on other sites

I was having simiar issues with my cmd prompt not recognizing python even after creating the new enviromental varialble named python.  I had to add it to my "Path" enviromental variable, AND either lower windows UAC (user account controls) to the point where you have admin rights, or create a Admin User Account that has the permissions you need (i just dropped my uac to a tolerable level). Only then did I get cmd to recognize python.

 

In short: make sure your cmd prompt window says Administrator:C:\Windows\....... in the upper left corner of of the windows title bar.

Share this post


Link to post
Share on other sites

I guess I have solved the error.

 

Below is the method that i had used

 

1. Copy the python.exe file at installed location.

 for me, It was "C:\Python34"

 

2. Paste it to here -> "C:\Windows\System32"

 

This method was worked for me.

 

Those who are still having problem with environmental variable, then try it.

This worked for me, thank you

Share this post


Link to post
Share on other sites

I have done all of the steps mentioned here to no avail. When I type ospPython into the command prompt it says "This .config file must be located in the same folder as ospPython.exe

ospPython.exe.config can be downloaded form gttps://github.com/OneStopProgramming/ospPython." 

Both ospPython.exe and ospPython.config.exe are clearly in the C:/Windows/System32 folder. I have altered the contents of the .config file in order for my updated python version to work. Any idea on why I'm getting this message?

Share this post


Link to post
Share on other sites

Changed it, still getting the same message. ""This .config file must be located in the same folder as ospPython.exe

ospPython.exe.config can be downloaded form gttps://github.com/OneStopProgramming/ospPython."

Share this post


Link to post
Share on other sites

Changed it, still getting the same message. ""This .config file must be located in the same folder as ospPython.exe

ospPython.exe.config can be downloaded form gttps://github.com/OneStopProgramming/ospPython."

A couple of things to try:

 

Double check that the path the python.exe is correct in the config file. Do this by taking the path and pasting it into the command line. For example:

C:\Python34\python.exe

Verify that you get the python interpreter. 

 

If that works, it may be a strange permission issue where the executable cannot read the config file. Try moving both files to a new folder in your documents folder named "ospPython". Then try executing the application like so:

C:\Users\[useraname]\Documents\ospPython\ospPython.exe

Share this post


Link to post
Share on other sites

I can get to the python interpreter using the first instructions, but I continue getting a syntax error using the command C:\Users\[useraname]\Documents\ospPython\ospPython.exe. Everything is definitely spelled correctly and in the right order. I have moved both files out of the system32 folder and into its own folder named "ospPython" in my Documents folder. 

Share this post


Link to post
Share on other sites

I've fixed the issue and now typing "ospPython" into the command promt brings up a python window. However when I change my directory to my desktop and type "ospPython helloworld.py" it quickly opens and closes a python window. Is this supposed to be hapening? 

Share this post


Link to post
Share on other sites

I've fixed the issue and now typing "ospPython" into the command promt brings up a python window. However when I change my directory to my desktop and type "ospPython helloworld.py" it quickly opens and closes a python window. Is this supposed to be hapening? 

 

Add input("Type something to exit") at the end of the program and see if that works. That should prevent it from closing automatically. 

Share this post


Link to post
Share on other sites

Thank you for this advice, it worked for me. Just out of curriousity though, does anyone have a link that will explain why this worked?

 

The path "C:\Windows\System32" path is in the system path so any executable in that folder can be run anywhere from the command line.

Share this post


Link to post
Share on other sites

i am sorry for asking the same stupid question as everyone else but i have tried every fix for this problem and nothing has worked. i am running windows 8.1 and cannot get cmd to recognize python

Sorry let me better explain where i am in the process. I have downloaded the ospPython.exe and the ospPython.exe.config files, but i when i go to edit them i cannot save it. it brings up and access denied and says i do not have administrative rights when i am the only user with administrative rights on this computer. please help.

Share this post


Link to post
Share on other sites

If your account is an administrator then when you right click on an exe there is usually an option that says "Run as administrator". You can also try right clicking it, selecting properties and there should be a tab like "Compatiblity" with an option you can select that says something along the lines of "Run this program as an administrator". Select it and that should take care of your access denied issue, btw I run Win7 and this is how you give administrator rights to programs, it should be similar for you.

Share this post


Link to post
Share on other sites

now i am getting an error saying please check to see if the file is open in another location.

I GOT IT!!! i must have done something worng from the get go, because i just uninstalled and went back to step one. now i got cmd to open python in another window! its not 100% like it shows in the tutorials but ill take it!

Share this post


Link to post
Share on other sites

After wrangling with this for a bit and subsequently breaking my original installation of python I have found the issue.

 

When installing there is an option that is left un-ticked 'Add Python.exe to Path'.

 

Select it to be installed on local drive and problems should disappear.

 

No need to install anything else or move folders around, just run the installer again> Un-install>Re-install with the correct option ticked.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now