A Python script is used on different platforms - Cygwin on Windows 10 and Linux on a Raspberry Pi. Some script parameters depend on the platform, so I am trying to read the value of the OSTYPE
environment variable. Although it is defined and readable from the command line, it is not defined in the script context.
Consider the following (copied from the Cygwin terminal, but is similar on the RPi terminal):
$ echo $TEMP
/tmp
$ echo $OSTYPE
cygwin
$ py3
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ.get('TEMP')
'C:\\cygwin64\\tmp'
>>> os.environ.get('OSTYPE')
>>> os.getenv('OSTYPE')
>>>
I also tryied export
-ing the variable, but got the same result.
Why is the OSTYPE
variable missing from Python's environment?