importError: no module named myapp in pyramid application

996 views Asked by At

i am a newbie in python.

I have created an application using pyramid framewok but i am getting an error which is

ImportError: No module named myapp

My stack Trace is as follows

2014-11-28 19:22:44,561 ERROR [pyramid_debugtoolbar][Dummy-1] Exception at http://127.0.0.1:9999/ traceback url: http://127.0.0.1:9999/_debug_toolbar/exception?token=a64896d3bad076fe2980&tb=140525154036112 Traceback (most recent call last): File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.2.2-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 177, in toolbar_tween response = _handler(request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.2.2-py2.7.egg/pyramid_debugtoolbar/panels/performance.py", line 57, in resource_timer_handler result = handler(request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/tweens.py", line 21, in excview_tween response = handler(request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_tm-0.8-py2.7.egg/pyramid_tm/__init__.py", line 92, in tm_tween reraise(*exc_info) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_tm-0.8-py2.7.egg/pyramid_tm/__init__.py", line 73, in tm_tween response = handler(request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/router.py", line 163, in handle_request response = view_callable(context, request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/config/views.py", line 377, in rendered_view context) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/renderers.py", line 418, in render_view return self.render_to_response(response, system, request=request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/renderers.py", line 441, in render_to_response result = self.render(value, system_values, request=request) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/renderers.py", line 421, in render renderer = self.renderer File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/decorator.py", line 37, in __get__ val = self.wrapped(inst) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid-1.5.2-py2.7.egg/pyramid/renderers.py", line 405, in renderer return factory(self) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_chameleon-0.3-py2.7.egg/pyramid_chameleon/zpt.py", line 10, in renderer_factory return renderer.template_renderer_factory(info, ZPTTemplateRenderer) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_chameleon-0.3-py2.7.egg/pyramid_chameleon/renderer.py", line 140, in template_renderer_factory return lookup(info) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pyramid_chameleon-0.3-py2.7.egg/pyramid_chameleon/renderer.py", line 115, in __call__ filename) File "/home/techencephalon/env/local/lib/python2.7/site-packages/pkg_resources.py", line 949, in resource_filename return get_provider(package_or_requirement).get_resource_filename( File "/home/techencephalon/env/local/lib/python2.7/site-packages/pkg_resources.py", line 229, in get_provider __import__(moduleOrReq) ImportError: No module named myapp

i have no idea about this error to get any idea to fix this.

I am using mongodb in this applicaiton.

2

There are 2 answers

0
Steve Piercy On

I recommend newbies work through the Quick Tutorial in order to get a solid understanding of how to develop web applications in Python using Pyramid as the medium.

0
srttowers On

I know that I'm years late but,

import in python using modules (pyramid uses) is a little bit tricky.

What I do is this:

for example, in views.py

from .tablas import julio2019
#import .tablas #if you want
ancho   =12
alto    = 7
color   ='#0CA309'
html4   = julio2019(ancho,alto,color)   

and tablas.py should be in the same directory as views.py

In your case, myApp maybe is not in the same directory or you omitted the dot. Note that, when using julio2019 function, its not necessary to use add tablas.julio2019(..) but you can if you want to.