Uwsgi-error: ImportError: No module named 'globals'

2,013 views
Skip to first unread message

Johann Spies

unread,
Sep 11, 2013, 5:11:07 PM9/11/13
to web...@googlegroups.com
I have (as far as I can see) identical configurations on two debian computers.  On one nginx with uwsgi works.  On the other, however, I get the following uwsgi-error in the logs:

Wed Sep 11 22:36:40 2013 - *** Operational MODE: preforking ***
Wed Sep 11 22:36:40 2013 - added /home/www-data/web2py/ to pythonpath.
Wed Sep 11 22:36:40 2013 - mounting wsgihandler:application on /
Traceback (most recent call last):
  File "/home/www-data/web2py/wsgihandler.py", line 33, in <module>
    import gluon.main
  File "/home/www-data/web2py/gluon/__init__.py", line 15, in <module>
    from globals import current
ImportError: No module named 'globals'
Wed Sep 11 22:36:40 2013 - unable to load app 0 (mountpoint='/') (callable not found or import error)


The pythonpath is correct and the web2py-installation is up to date and there is a globals.py in web2py/gluon

What is going on?

Regards
Johann

--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Massimo Di Pierro

unread,
Sep 11, 2013, 9:52:18 PM9/11/13
to web...@googlegroups.com
In both cases print the sys.path.

Niphlod

unread,
Sep 12, 2013, 3:18:32 AM9/12/13
to web...@googlegroups.com
usually this is due to gluon not being in sys.path directly.

BTW: we  should adopt something standard in imports too throughout all the code. Either we do 
from gluon.module import something
or
from module import something

I vote for the 1st option.

Massimo Di Pierro

unread,
Sep 12, 2013, 9:06:34 AM9/12/13
to web...@googlegroups.com
I agree. Less ambiguitiy

Michele Comitini

unread,
Sep 12, 2013, 5:26:17 PM9/12/13
to web...@googlegroups.com
+1



2013/9/12 Massimo Di Pierro <massimo....@gmail.com>

--
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Niphlod

unread,
Sep 12, 2013, 5:33:56 PM9/12/13
to web...@googlegroups.com
so let's go for all imports done prefixing them with gluon or the other one ? I'll put it in the roadmap ^_^

Johann Spies

unread,
Sep 13, 2013, 5:48:58 AM9/13/13
to web...@googlegroups.com
On 12 September 2013 03:52, Massimo Di Pierro <massimo....@gmail.com> wrote:

In both cases print the sys.path.


On 'spyker' where the problem is:

$ python web2py.py -M -S alterit
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.5.1-stable+timestamp.2013.06.06.15.39.19
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib)
Python 2.7.5+ (default, Jun  2 2013, 13:26:34)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import sys

In [2]: print sys.path
['', '/home/www-data/web2py/gluon', '/home/www-data/web2py/site-packages', '/home/www-data/web2py', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/dist-packages/IPython/extensions']


On the other one:

$ python web2py.py -M -S alterit
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.5.1-stable+timestamp.2013.06.06.15.39.19
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib)
Python 2.7.5+ (default, Jun 13 2013, 13:26:49)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import sys

In [2]: print sys.path
['', '/home/www-data/web2py/gluon', '/home/www-data/web2py/site-packages', '/home/www-data/web2py', '/usr/local/lib/python2.7/dist-packages/tiffany-0.6-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/dist-packages/IPython/extensions']


When I add the lines used in uwsgihandler.py I get:

In [11]: import sys

In [12]: import os

In [13]:

In [13]: path = os.path.dirname(os.path.abspath(__file__))

In [14]: os.chdir(path)

In [15]: sys.path = [path] + [p for p in sys.path if not p == path]

In [16]: print sys.path
['/home/www-data/web2py/applications/alterit/models', '', '/home/www-data/web2py/gluon', '/home/www-data/web2py/site-packages', '/home/www-data/web2py', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/dist-packages/IPython/extensions']

This does not really show me the root of the problem.

nils

unread,
Sep 13, 2013, 12:12:35 PM9/13/13
to web2py-users
Hi,

I had a problem along the same lines, it turned out that uwsgi was compile with python 3.3 support.

This was Ubuntu 13.04 and I installed it via apt-get , check the entire uwsgi logs for the python version.

regards,

Nils


Michele Comitini

unread,
Sep 13, 2013, 3:05:39 PM9/13/13
to web...@googlegroups.com
@niphlod I'd prefer having everything under the gluon namespace

import gluon.<module>


2013/9/13 nils <ni...@olofsson.tv>

Massimo Di Pierro

unread,
Sep 13, 2013, 4:16:50 PM9/13/13
to web...@googlegroups.com
This is now done in 2.6.1

Johann Spies

unread,
Oct 4, 2013, 6:00:08 PM10/4/13
to web...@googlegroups.com
On 13 September 2013 18:12, nils <ni...@olofsson.tv> wrote:
 
I had a problem along the same lines, it turned out that uwsgi was compile with python 3.3 support.

This was Ubuntu 13.04 and I installed it via apt-get , check the entire uwsgi logs for the python version.


Thanks for this.  I only came back to this problem today and indeed: the problem installation's uwsgi was compiled for python3.3!

Regards
Johann
Reply all
Reply to author
Forward
0 new messages