Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Python KeyError with configparser?

$
0
0

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 = 7MIN_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'

Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>