How do I Open Audacity With Python?

How do I open Audacity with python? Any ideas?


I already tried using and a window from Audacity popped up saying, “This text file ‘Audacity’ seems to be an executable script. What do you want to do with it?” The options were: Execute, Execute in Terminal, Open, and the last option was Cancel. How do I make this pop-up not occur?
This is my code for it:

import subprocess'xdg-open', '/home/pi/raspberrypi/.local/share/applications/audacity.desktop'))

This works for me on Ubuntu 22.04:

import subprocess

Can you run it from Terminal…go to the Audacity executable file folder… get its name then run … ./filename
If that works put it in your .profile as a line to run at startup… this will be a shell script

is the filesname… audacity.desktop… or is that the name of a script for running from desktop.

Would this work for RPI startup?

What do you mean?

You say you have Audacity installed… but how are you running it now… just from menu…??
Is that not OK… Are you wanting Audacity to start up after bootup without any user intervention…? here is a link may be of help…
How to Run a Raspberry Pi Program on Startup - SparkFun Learn

Edited this post 30 mins later…
I have just tried the option Method2 autostart, Create a .desktop file as shown in the Sparkfun link and it works…
[Desktop Entry]

Then do a reboot and Audacity runs when linux restarts.
I am using Debian Linux 10 Buster on an antique laptop.
This is probably using only shell script as python3 is not called…?
I don’t know why I would want it on startup, so I will take it off again…probably

So if I make a .desktop file, and add what you said, when my pi boots it would run it and open Audacity?

Yes, the link in last post is specifically for Raspberry Pi so follow it exactly and do Method 2 autostart
Open Terminal and do all from the command line…
Check out your home directory and see has it a .config folder …probably has … but it may not have an autostart folder so create it as below…
nano is a text editor you can use it or vi or vim whatever and create a file in the autostart folder called audacity.desktop and type in the 4 lines of text as below and save the file.

mkdir /home/pi/.config/autostart
nano /home/pi/.config/autostart/audacity.desktop

[Desktop Entry]

Then reboot to see if it works.
If it cannot find audacity you will have to put in the full path or add its path to $PATH
You can probably find this out before you do anything… when you login to terminal at the command prompt simply type … audacity … If audacity opens then your path will be OK.

If you still want to do with python then follow what is does in the link.

It worked! Thank you! There is only one thing (unrelated). When you said to type “audacity” in terminal to see if I needed to add the full $PATH, I typed it, I got this giant block of text. (After it stopped writing it opened Audacity) I don’t know what it is, does, or will do. Do you know?
Below is the file: (the error (or whatever it was) was really long)
error.txt (66.8 KB)

I don’t think that’s a problem. It looks to me like “normal” debugging information, which is not normally seen since Audacity is normally run from a launcher.

If you search that file for the word “error”, the only occurrences are while Audacity is scanning the sound system to see what audio devices are available. Audacity checks lots of options, only some of which will be valid for any particular system - options that are not supported by the system appear in that output.

Yes, I dont think its a problem, I get similar list if I just run audacity from the command line. Are you still getting the the long list when running from autostart after reboot…?

Did you install the GUI when you installed linux/raspain on the pi… if so you probably have an audacity.desktop in /usr/share/applications that will be the one used by the GUI menus or short cut etc when you click to open it. You could try copy that one to your .config/autostart and see if it runs better.

No, I’m not getting that when I reboot.

This topic was automatically closed after 30 days. New replies are no longer allowed.