Converting from midi to xml on command line Ubuntu Server - Error
Hi,
I am trying to convert from midi to xml on an Ubuntu Server using the command line. I am getting the following error.
mscore.real: cannot connect to X server
Is there anyway to use mscore from the command line in Ubuntu?
Comments
Also seeing this issue with Musescore versions 1.3 and 2.0 when attempting to run on an Ubuntu 14.04 Amazon EC2 instance. Musescore has some great command line capabilities and this seems to be somewhat common for people to need a way to use them without an X server so I figured I'd make some noise here. I did find a workaround, thankfully, but it requires the installation of a virtual X server.
Attempting to run the following command fails (This conversion is the opposite of what OP jt419oh posted):
musescore out.xml -o out.mid
The following error messages occur with 1.3 and 2.0, respectively:
mscore.real: Cannot connect to X server
QXcbConnection: Could not connect to display
I've attempted the workaround suggested by "fatAngel", except with the Ubuntu setup mentioned above and this works. See the URL:
https://musescore.org/node/8970
This workaround needs the following steps (Only tried this with 1.3 so far):
*Install Xvfb:
sudo apt-get install Xvfb
*Start Xvfb in the background (ignore font errors and press enter if prompt doesn't show up):
Xvfb :0 -screen 0 1280x768x24&
*Let the OS know which display to use (we're using ':0' here)
export DISPLAY=:0
After these steps, Musescore 1.3 and 2.0 command line functionality works "headless". BOOM!
In reply to Also seeing this issue with by ryansdavis
Another simpler way is to just set “QT_QPA_PLATFORM” environment variable to “offscreen” — no need for xvfb at all. Tested with MuseScore 2.1.
In reply to Another simpler way is to… by p-himik
Thank you!! Confirming that this also works in a jupyter notebook, where I was running into trouble (using music21's musescore integration).
I did this in a notebook cell to fix my music21/musescore3 issues::
%env QT_QPA_PLATFORM=offscreen