glass.py icon indicating copy to clipboard operation
glass.py copied to clipboard

Running examples

Open ktal90 opened this issue 11 years ago • 10 comments

After installing the requirements and the library as per the installation instructions, I cannot run any of the examples. It looks to me that Python is having trouble importing the modules. This is what I am hit with after trying to run the "hello.py" example:

Traceback (most recent call last):
File "examples/hello.py", line 2, in
import glass
File "/home/action/.local/lib/python2.7/site-packages/glass/init.py", line 1, in
from app import Application
File "/home/action/.local/lib/python2.7/site-packages/glass/app.py", line 2, in
import flask
File "/home/action/.local/lib/python2.7/site-packages/flask/init.py", line 17, in
from werkzeug.exceptions import abort
File "/home/action/.local/lib/python2.7/site-packages/werkzeug/init.py", line 154, in
import('werkzeug.exceptions')
File "/home/action/.local/lib/python2.7/site-packages/werkzeug/exceptions.py", line 71, in
from werkzeug.wrappers import Response
File "/home/action/.local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 36, in
from werkzeug.utils import cached_property, environ_property, \
File "/home/action/.local/lib/python2.7/site-packages/werkzeug/utils.py", line 18, in
from html.entities import name2codepoint
File "/home/action/workspace/glass.py/examples/html.py", line 7, in
app = glass.Application(
AttributeError: 'module' object has no attribute 'Application'

ktal90 avatar Sep 09 '13 04:09 ktal90

Hum, what system are you using ? Can you past me the error in a gist (better format for reading it).

SamyPesse avatar Sep 10 '13 07:09 SamyPesse

I have tried both through the cloud (Nitrous.io) as well as Ubuntu xcfe4. I installed all dependencies (I think). Don't know what it could be.

Here is my trace: https://gist.github.com/ktal90/866255d551344923ce92#file-gistfile1-txt

ktal90 avatar Sep 10 '13 15:09 ktal90

Ok, I'll check this out and come back to you as soon as I can.

SamyPesse avatar Sep 11 '13 22:09 SamyPesse

Can you check if you have modules names conflict ? Or can you give the code in a GitHub repo or a ZIP or put it on friendco.de

SamyPesse avatar Sep 11 '13 22:09 SamyPesse

Hmm looking at my modules, it doesn't look like there are any conflicts. I have python running, have installed the requirements with pip, and then installed the glass library. What I think may be the problem is importing "configs" in the second command of your examples. How is python referencing configs.py? Hmm what am I doing wrong?

ktal90 avatar Sep 15 '13 23:09 ktal90

Hmm interesting. It looks like there is a problem finding the package when running the server that you just added. I added the callback to my api console, but no luck. In fact, the error seems to be with finding the library itself:

INFO 2013-09-15 23:48:13,856 sdk_update_checker.py:244] Checking for updates to the SDK. INFO 2013-09-15 23:48:14,019 api_server.py:138] Starting API server at: http://localhost:52046 INFO 2013-09-15 23:48:14,127 dispatcher.py:164] Starting server "default" running at: http://0.0.0.0:3000 INFO 2013-09-15 23:48:14,131 admin_server.py:117] Starting admin server at: http://localhost:8000 ERROR 2013-09-15 23:48:20,172 wsgi.py:219] Traceback (most recent call last): File "/home/action/.google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/home/action/.google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler handler = __import__(path[0]) File "/home/action/workspace/glass.py/examples/appengine-buildout/app/main.py", line 7, in <module> import glass ImportError: No module named glass INFO 2013-09-15 23:48:20,203 server.py:593] default: "GET / HTTP/1.1" 500 - ERROR 2013-09-15 23:48:21,267 wsgi.py:219] Traceback (most recent call last): File "/home/action/.google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/home/action/.google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler handler = __import__(path[0]) File "/home/action/workspace/glass.py/examples/appengine-buildout/app/main.py", line 7, in <module> import glass ImportError: No module named glass

ktal90 avatar Sep 15 '13 23:09 ktal90

Hi @ktal90, In this most recent stacktrace it looks like you are trying to run the google appengine + zc.buildout example. Since this example uses zc.buildout to manage your app dependencies you must follow the setup instructions from the README file here:

https://github.com/SamyPesse/glass.py/blob/master/examples/appengine-buildout/README.md

This example uses mr developer to fetch a copy of glass.py into the project's dist folder

hello-josh avatar Sep 16 '13 03:09 hello-josh

Awesome. Thanks a lot @Trii ! I guess these are two separate issues really (1. appengine and 2. the example scripts). I'm still unable to run hello.py and other examples. Let me know if you have any tips based on the first trace I posted. Thanks!

ktal90 avatar Sep 16 '13 04:09 ktal90

I will try to run hello.py today and some others and let you know.

hello-josh avatar Sep 16 '13 15:09 hello-josh

To run examples/hello.py from that folder I had to remove both examples/html.py and examples/html.pyc. Alternatively, just move the hello.py somewhere else.

It's a circular import. As it seems, glass imports werkzeug, which tries to import another package named html but loads html.py instead, which again tries imports glass.

File "/home/action/.local/lib/python2.7/site-packages/werkzeug/utils.py", line 18, in
from html.entities import name2codepoint
File "/home/action/workspace/glass.py/examples/html.py", line 7, in 

balkian avatar Mar 09 '14 12:03 balkian