Audacity Pipe Python Errno 22

Good afternoon all,

I’m trying to use Python 3.7 (Windows 10, Audacity 2.4.2) to send commands to Audacity using the pipe. I enabled mod-script-pipe and restarted Audacity (several times), so that seems to be all good. However, I have trouble opening and writing to the pipe.

On a first run of pipe_test.py I get the following output:

pipe-test.py, running on windows
Traceback (most recent call last):
Write to  "\\.\pipe\ToSrvPipe"
Read from "\\.\pipe\FromSrvPipe"
-- Both pipes exist.  Good.
  File "C:/Users/chris/PycharmProjects/Youtube-Spotify-DL/pipe_test.py", line 44, in <module>
    TOFILE = open(TONAME, 'w')
OSError: [Errno 22] Invalid argument: '\\\\.\\pipe\\ToSrvPipe'

So, it seems the pipe exists but it cannot be written to. When I run the script again, I get a slightly different response:

pipe-test.py, running on windows
Write to  "\\.\pipe\ToSrvPipe"
 ..does not exist.  Ensure Audacity is running with mod-script-pipe.

The second time it appears that the pipe is not running anymore. Restarting audacity yields the first error again. I’ve been browsing for the past hour, and it seems I’m not the only person encountering this error. However, I haven’t found a fix yet. Any help would be much appreciated.

Cheers,

Chris

I found that the script does work when ran through IDLE instead of Pycharm. Most like because of the way it calls the Python interpreter?

I generally just use the command line (on Windows that’s like running Python in a cmd window).
Pycharm may be running the code in a sandbox, and that could prevent Python from writing to the pipe.

That’s indeed an option! However, I want to time Audacity commands with playing tracks, so this has to be automated and timed properly. Do you know of any workaround? I’m currently looking into sending commands to sys (from Pycharm) to run another Python script that sends commands to the pipe.

Pycharm is a development environment, and not intended to be used for the normal running of Python programs.

What exactly do you want to time? The time taken between sending a command and receiving a reply from Audacity?

I’m referring to synchronizing my audio source and Audacity. I’m writing a script to download entire playlists, so I want to coordinate playing tracks, recording, exporting, and so on.

What’s the problem that you want to work around?

I believe I just asked a similar question.
Can the pipe be automated and not rely on manual entry of commands?

I have replied to your question here: pipeclient.py question