'Python KeyError with configparser?
I need your help after I tried everything in my hands with no luck.
Please Note: My code runs perfect on macOS, the problem discussed is regarding Windows OS.
I have the following line in python:
if int(major) < int(config['NMAP']['MIN_MAJOR']) or (
where:
config = configparser.ConfigParser()
config.read('config.ini')
and the contents of the config file are:
[NMAP]
MIN_MAJOR = 7
MIN_MINOR = 92
[FING]
When I run my file I get:
File "C:\Users\dc\src\network_scanner\nmap_scanner.py", line 15, in __init__
if int(major) < int(config['NMAP']['MIN_MAJOR']) or (
File "C:\Users\usr\AppData\Local\Programs\Python\Python310\lib\configparser.py", line 964, in __getitem__
raise KeyError(key)
KeyError: 'NMAP'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
