I have a copy of the music21 python library in the modules folder of my
application.
>From the pythonanywhere bash prompt I can import it without problems:
cd ~/web2py/applications/mints/modules
python
>>> from music21 import chord
>>> chord
<module 'music21.chord' from 'music21/chord.pyc'>
When I tried to import it from my application, at first I got the following
stack trace:
*controller:*
def index():
from music21 import chord
return dict(message=T('Hello World'))
*Error: *
<type 'exceptions.ImportError'> cannot import name correlate
Versie
web2py™ Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Python Python 2.7.5+: /usr/local/bin/uwsgi (prefix: /usr)
Traceback (most recent call last):
File "/home/xxx/web2py/gluon/restricted.py", line 220, in restricted
exec ccode in environment
File "/home/xxx/web2py/applications/mints/controllers/default.py", line
79, in <module>
File "/home/xxx/web2py/gluon/globals.py", line 385, in <lambda>
self._caller = lambda f: f()
File "/home/xxx/web2py/applications/mints/controllers/default.py", line
21, in index
from music21 import chord
File "/home/xxx/web2py/gluon/custom_import.py", line 92, in
custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/mints/modules/music21/__init__.py", line 166, in
<module>
from music21 import * # @UnresolvedImport
File "/home/xxx/web2py/gluon/custom_import.py", line 92, in
custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/mints/modules/music21/analysis/__init__.py", line 5,
in <module>
from music21.analysis import correlate
ImportError: cannot import name correlate
After *reloading* the web application, the trace back changed to:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
Traceback (most recent call last):
File "/home/xxx/web2py/gluon/restricted.py", line 220, in restricted
exec ccode in environment
File "/home/xxx/web2py/applications/mints/controllers/default.py"
<https://stefaanhimpe.pythonanywhere.com/admin/default/edit/mints/controllers/default.py>,
line 79, in <module>
File "/home/xxx/web2py/gluon/globals.py", line 385, in <lambda>
self._caller = lambda f: f()
File "/home/xxx/web2py/applications/mints/controllers/default.py"
<https://stefaanhimpe.pythonanywhere.com/admin/default/edit/mints/controllers/default.py>,
line 21, in index
from music21 import chord
File "/home/xxx/web2py/gluon/custom_import.py", line 92, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/mints/modules/music21/__init__.py", line 166, in <module>
from music21 import * # @UnresolvedImport
File "/home/xxx/web2py/gluon/custom_import.py", line 92, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/mints/modules/music21/analysis/__init__.py", line 7, in
<module>
from music21.analysis import metrical
File "/home/xxx/web2py/gluon/custom_import.py", line 92, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/mints/modules/music21/analysis/metrical.py", line 18, in
<module>
import music21.stream
File "/home/xxx/web2py/gluon/custom_import.py", line 86, in custom_importer
raise ImportError, 'Cannot import module %s' % str(e)
ImportError: Cannot import module 'music21'
Do you think this is a problem in web2py? or rather in the library?
If you have an idea about what causes the problem, can it be worked around
somehow?
thanks for your insights!
Best regards,
Stefaan.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.