
from server.tsuserver import TsuServer3

# Idiotproof setup
def check_pyyaml():
    try:
        import yaml
    except ImportError:
        print("Couldn't import PyYAML. Installing it for you...")
        import pip
        pip.main(["install", "--user", "pyyaml"])

def main():
    server = TsuServer3()
    server.start()


if __name__ == '__main__':
    check_pyyaml()
    main()


from server.tsuserver import TsuServer3

# Idiotproof setup
def check_pyyaml():
    try:
        import yaml
    except ModuleNotFoundError:
        print("Couldn't import PyYAML. Installing it for you...")
        import pip
        pip.main(["install", "--user", "pyyaml"])

def main():
    server = TsuServer3()
    server.start()


if __name__ == '__main__':
    check_pyyaml()
    main()

Use ModuleNotFoundError instead of ImportError
Use ModuleNotFoundError instead of ImportError

  
  from server.tsuserver import TsuServer3
  
  # Idiotproof setup
  def check_pyyaml():
      try:
          import yaml
-     except ImportError:
+     except ModuleNotFoundError:
          print("Couldn't import PyYAML. Installing it for you...")
          import pip
          pip.main(["install", "--user", "pyyaml"])
  
  def main():
      server = TsuServer3()
      server.start()
  
  
  if __name__ == '__main__':
      check_pyyaml()
      main()
  
Use ModuleNotFoundError instead of ImportError
## Code Before:

from server.tsuserver import TsuServer3

# Idiotproof setup
def check_pyyaml():
    try:
        import yaml
    except ImportError:
        print("Couldn't import PyYAML. Installing it for you...")
        import pip
        pip.main(["install", "--user", "pyyaml"])

def main():
    server = TsuServer3()
    server.start()


if __name__ == '__main__':
    check_pyyaml()
    main()

## Instruction:
Use ModuleNotFoundError instead of ImportError
## Code After:

from server.tsuserver import TsuServer3

# Idiotproof setup
def check_pyyaml():
    try:
        import yaml
    except ModuleNotFoundError:
        print("Couldn't import PyYAML. Installing it for you...")
        import pip
        pip.main(["install", "--user", "pyyaml"])

def main():
    server = TsuServer3()
    server.start()


if __name__ == '__main__':
    check_pyyaml()
    main()
