Forum Archive

Music21 Package

scj643

Wondering if it is possible to get http://web.mit.edu/music21/ working in pythonista. Been wanting to process music data in python and have pythonista be part of my music production workflow.

dgelessus

It looks like it's pure Python. Why not try installing it and see if it works for you?

scj643

There are a bunch of issues when trying to import it

dgelessus

What exactly? If you get an error message or traceback, please copy and paste it here, otherwise it's a little hard to tell what the problem is. ;)

scj643

Traceback (most recent call last):
File "", line 1, in
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/init.py", line 139, in
from music21 import base
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/base.py", line 80, in
from music21.sites import SitesException
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/sites.py", line 19, in
from music21 import common
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/common/init.py", line 45, in
from music21.common.misc import * # most are deprecated!
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/common/misc.py", line 31, in
import multiprocessing
ImportError: No module named multiprocessing

scj643

Multiprocessing is supposed to be in the standard library iirc

omz

@scj643 multiprocessing isn't supported in Pythonista because iOS apps can't spawn child processes (App Store / sandboxing rules). I'm not sure how much music21 actually depends on it. You may be able to fake it by putting an empty multiprocessing.py file in the site-packages folder...

dgelessus

I only looked at the music21 source code very briefly, but apparently it supports multiple "backends" for the work it does, and one of them uses multiprocessing. As @omz said, it might be enough to put a fake multiprocessing.py into site-packages (or download the real one from the Python Mercurial repo). You might need to check how you can switch the backend, the multiprocessing one might be the default.

@omz Since you've already included subprocess even though it can't be used, wouldn't it make sense to also include the other standard modules that depend on forking? Then importing them will work at least.

scj643

adding a fake multiprocessing then reveals a new issue

Traceback (most recent call last):
File "", line 1, in
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/init.py", line 139, in
from music21 import base
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/base.py", line 76, in
from music21 import exceptions21
ImportError: cannot import name exceptions21猀

omz

@scj643 I haven't tried this, but what's with the '猀' character at the end there? Was that actually in the traceback?

Webmaster4o

@omz Doubt it, because that's not in the line before.

scj643

New trace back error log

Traceback (most recent call last):
File "", line 1, in
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/init.py", line 167, in
from music21 import * # @UnresolvedImport # pylint: disable=wildcard-import
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/abcFormat/init.py", line 47, in
from music21.abcFormat import translate
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/abcFormat/translate.py", line 32, in
from music21 import stream
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/stream/init.py", line 44, in
from music21 import metadata
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/metadata/init.py", line 51, in
from music21.metadata import caching
File "/private/var/mobile/Containers/Shared/AppGroup/5FD2FDE6-F810-4A9A-B188-772796B31F62/Documents/site-packages/music21/metadata/caching.py", line 414, in
class WorkerProcess(multiprocessing.Process): # @UndefinedVariable pylint: disable=inherit-non-class
AttributeError: 'module' object has no attribute 'Process'