Answer the question
In order to leave comments, you need to log in
Why is the variable not added to the virtual environment?
Python2.7, windows10
Hello everyone!
I add to the activate file of the virtual environment, which is in Scripts, the lines
test_value="awdaDWAD"
export test_value
Next, I activate the virtual environment, go to the shell, import os, then print os.getenv('test_value').
I get None.
Why?
How to add variables to virtual environment?
Answer the question
In order to leave comments, you need to log in
I usually do this:
activate :
export SOME_KEY = 'foobar'
settings.py :
SOME_KEY = os.getenv('SOME_KEY')
or use dotenv
[email protected] ~ $ test_value="awdaDWAD" python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print os.getenv('test_value')
awdaDWAD
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question