Reputation: 29
I am currently debugging a script and i believe the issue is the configuration file not being read (jupyter notebook). I can confirm both the script and the .config
file is located in the below directory
os.getcwd()
'C:\\Users\\User'
pwd
---output---
'C:\\Users\\User'
below here is the attempt to read the file
configParser = configparser.RawConfigParser()
config_path = r'C:\Users\User\cartpole.config'
configParser.read(config_path)
---output---
['C:\\Users\\User\\cartpole.config']
config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
config_path)
population = neat.Population(config)
How would i go about printing the configuration file to confirm if its being read?
Thank you.
Upvotes: 0
Views: 466
Reputation: 887
If you just want to print the file:
with open('C:\\Users\\User\\cartpole.config', 'r') as f:
for line in f:
print(line)
EDIT: To make sure that you reference the same file:
configParser = configparser.RawConfigParser()
config_path = r'C:\Users\User\cartpole.config'
with open(config_path, 'r') as f:
for line in f:
print(line)
configParser.read(config_path)
If you find yourself in the situation where the config file is correct, but you still do not see your configurations, the problem is probably in your ConfigParser
class.
Upvotes: 1