0

I would like to set PYTHONIOENCODING env variable to be permanently set to utf-8 in a particular virtualenv. So whenever I activate my virtualenv using

source py/bin/activate

my setting of PYTHONIOENCODING=utf-8 will be automatically activated as well.

I followed virtualenv manual and tried the following

echo $PYTHONIOENCODING ## expected unset

env PYTHONIOENCODING=utf-8 virtualenv py --python=/usr/bin/python3.6
#Running virtualenv with interpreter /usr/bin/python3.6
#...
echo $PYTHONIOENCODING ## expected unset

source py/bin/activate
echo $PYTHONIOENCODING ## expected to be set here

but it didn't work (expected to last command return utf-8).

How can this be achieved?

jangorecki
  • 16,384
  • 4
  • 79
  • 160
  • https://stackoverflow.com/search?q=%5Bvirtualenv%5D+set+environment+variable – phd Jan 12 '21 at 12:39
  • @phd Could you please tell me which of linked 3 questions provide the answer to my question? I see only workarounds there – jangorecki Jan 12 '21 at 14:02
  • All 3. Which one you choose is up to you. – phd Jan 12 '21 at 14:03
  • @phd In none of them I am finding solution with virtualenv. If the answer to my Q is "it cannot be achieved using virtualenv only", then it is a still valid answer. No reason to close question. – jangorecki Jan 12 '21 at 14:04

0 Answers0