Errors with scripting API

Hi so I want to use Audacity’s API as part of a mini project I’m doing.

I downloaded the test script ‘pipe_test.py’ and ran the code and I’m having the biggest headache trying to get this to work.

Sometimes the script works fine and there’s no problem.

Sometimes I’ll get this error:
Write to “\.\pipe\ToSrvPipe”
…does not exist. Ensure Audacity is running with mod-script-pipe.

To remedy this I restart Audacity and I get this error:
Traceback (most recent call last):
File “C:\Users\66931\Documents\Python\pipe_test.py”, line 44, in
TOFILE = open(TONAME, ‘w’)
OSError: [Errno 22] Invalid argument: ‘\\.\pipe\ToSrvPipe’

If I spam run the script it’ll maybe work but eventually I’ll get the error I stated before.

I’m genuinely at a loss and I don’t know what to do.

I’m running the latest version of Audacity, Atom’s IDE, and am on Windows 10.

Given the recent flurry of releases, which version are you referring to? (look in “Help menu > About Audacity”)

Where do you get that error? In Atom?

Which version of Python are you using?

Have you tried running the script in a Python shell? (Start Python in a “cmd” window)

For some reason everything works as it should, but I believe the issue should still be explored.

I would get the error message whether I ran the python program in power-shell or in the Atom IDE.
I am using the latest version of Python from the Microsoft store so Python 3.8.

Ever since restarting my computer and just letting my computer rest for a bit it somehow works all the time.

I’ve been using Python scripting quite a bit recently - mostly on Linux but also on Windows 10.
On Windows I was running Python from IDLE.

I did not encounter the problem that you described.
If you find a repeatable way to produce the error, please do let us know.