0

When I run a python script with the following lines:

import os

host = os.environ.get('HOST')
if (host):
   print(host)

I get an MKS Toolkit for Win32 prompt that says "MKS Toolkit for Win32 has stopped working."

Without those lines, the file runs fine. This is occurring on a Windows Server 2008 R2 computer. It works fine on Windows 7. Any ideas?

  • Does it stop at the os.environ.get call? Is os.environ defined? Does it have the 'HOST' entry? – mirabilos Dec 06 '13 at 21:24
  • I'm not sure which line causes the prompt. However, after I close the prompt and the script finishes, I look at the log file and it shows an "AttributeError: __getitem__" exception on the host definition line. os.eniron should be defined by import os, right? 'HOST' does not exist as an environment variable. But that just means os.environ.get('HOST') should just return None. – user3076050 Dec 06 '13 at 21:31
  • Well you could have just added the first line of the three, and seen if it still occurs. But the AttributeError says enough: os.environ is most likely _not_ provided by your Python version. (I get `None` on `os.environ.get('something_undefined')` on Unix.) – mirabilos Dec 06 '13 at 21:55

0 Answers0