Python Modify Os Path Variable
I am going to try and say this right but it's a bit outside my area of expertise. I am using the xgboost library in a windows environment with Python 2.7 which requires all kinds o
Solution 1:
The os.environ
function is only inside the scope of the python/jupyter console:
Here's evidence of this in my bash shell:
$ export A=1$ echo$A
1
$ python -c "import os; print(os.environ['A']); os.environ['A'] = '2'; print(os.environ['A'])"
1
2
$ echo$A
1
The python line above, prints the environ variable A
and then changes it's value and prints it again.
So, as you see, any os.environ
variable is changed within the python script, but when it gets out, the environment of the bash shell does not change.
Another way of doing this is to modify your User or System PATH
variable. But this may break other things because what you're doing may replace the default compiler with mingw and complications may arise. I'm not a windows expert, so not sure about that part.
In a nutshell:
- The os.environ manipulations are local only to the python process
- It won't affect any other program
- It has to be done every time you want to import xgboost
Post a Comment for "Python Modify Os Path Variable"