Please take a look at our Knowledge Article that provides a solution to the behavior that you're seeing:
"Error -200077 Using Analog Output Task in Python"
You'll need to change the way you define the task as described in that article.
I try the code you recommended:
with nidaqmx.Task() as task:
task.ao_channels.add_ao_voltage_chan("Dev1/ao0", 0, 5,)
print('1 Channel 1 Sample Write: ')
It does not work, it gives the same error!
OK, now it works I forgot name_to_assign_to_channel which even if you do not have specified you have to add ''!