from os import system from subprocess import getoutput from time import sleep
instead of
import os, subprocess, time
but when I try to import from a module I'm getting this error when I run my program:
NameError: global name 'os' is not defined
This is the part of the code that I'm using os in:
from os import system from subprocess import getoutput from time import sleep class FanControl: def __init__(self): try: SettingsFile = open('settings.txt', 'r') except IOError: import CreateSettings else: FanControl.EnableFanSettings(SettingsFile) def EnableFanSettings(SettingsFile): os.system('nvidia-settings -a [gpu:0]/GPUFanControlState=1') os.system('nvidia-settings -a [gpu:1]/GPUFanControlState=1') os.system('nvidia-settings -a [gpu:2]/GPUFanControlState=1') os.system('nvidia-settings -a [gpu:3]/GPUFanControlState=1')
Why am I getting an error when I import a function from a module but not when I import the entire module?