I want to set the environment variable for python. I had did all the stuff as to add in system variable under system path or even pythonpath. Even same under user variable but continuously getting error "PYTHONPATH
' is not recognized as an internal or external command, operable program or batch file."
Asked
Active
Viewed 1,369 times
0

Mike
- 4,041
- 6
- 20
- 37

nikhil ranjan
- 1
- 1
-
1Can you please describe the problem you are trying to solve. – Burhan Khalid Dec 07 '18 at 07:11
-
Possible duplicate of https://stackoverflow.com/questions/30006722/os-environ-not-setting-environment-variables and other questions. – quant Dec 07 '18 at 07:16
-
Showing the command that causes the error with the exact full text of the error message, and giving the underlying OS could help in getting relevant answers. – Serge Ballesta Dec 07 '18 at 07:49
-
Possible duplicate of [How do I make environment variable changes stick in Python?](https://stackoverflow.com/questions/488366/how-do-i-make-environment-variable-changes-stick-in-python) – Josef Ginerman Dec 07 '18 at 11:34
1 Answers
0
By the type of error you are facing It's clear that you have problem installing python on windows. You did installed it, But it's env variables is not set and in your cmd you can not access it and gave you that error.
Follow this instruction Add Python to the PATH Environmental Variable
Also If you want to work with environment variables in python, you should use os
module. like this:
to set value:
os.environ['myEnv'] = 'something'
to get value: os.environ.get('myEnv', 'defaultValue')
And remember if you set an environment variable, that variable is accessed only in context of your python code and will not be global for other applications.

Reza Torkaman Ahmadi
- 2,958
- 2
- 20
- 43