I just fresh installed web2py on ubuntu 12.04, cannot find modules?

168 views
Skip to first unread message

Kenneth

unread,
May 2, 2013, 9:08:31 PM5/2/13
to web...@googlegroups.com
This seems odd to me.

I just moved my server and ran the ubuntu script to install web2py

I cannot import simplejson for some reason. (I ran it on python -S web2py.py as well)

anyone had this problem before? Let me know! Otherwise, I have to import directly from gluon.
Message has been deleted

Kenneth

unread,
May 2, 2013, 9:17:00 PM5/2/13
to web...@googlegroups.com
Ubuntue is 12.04 64bit server, fresh installed. 
This is what I received after "import simplejson"


web2py™Version 2.4.6-stable+timestamp.2013.04.06.17.37.38
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/www-data/web2py/applications/welcome/controllers/default.py", line 78, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 194, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/applications/welcome/controllers/default.py", line 22, in index
import simplejson
File "/home/www-data/web2py/gluon/custom_import.py", line 81, in custom_importer
raise ImportError, 'Cannot import module %s' % str(e)
ImportError: Cannot import module 'simplejson'

Anthony

unread,
May 2, 2013, 9:26:12 PM5/2/13
to web...@googlegroups.com
It's contrib.simplejson.

Kenny Chung

unread,
May 2, 2013, 9:27:07 PM5/2/13
to web...@googlegroups.com
Hi Anthony,

So, should I just import "contrib.simplejson"? Is this recently changed?

Ken

It's contrib.simplejson.
--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/qRO3Lzm9hWs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Anthony

unread,
May 2, 2013, 9:36:47 PM5/2/13
to web...@googlegroups.com
I think that's where it has always been.

Kenny Chung

unread,
May 2, 2013, 9:38:58 PM5/2/13
to web...@googlegroups.com
Ouch. I must have used old version of web2py than.
I always imported simplejson as "import simplejson as json" 
I totally forgot to replicate my setup before terminating my linode server.

Ken

Alan Etkin

unread,
May 2, 2013, 9:46:32 PM5/2/13
to web...@googlegroups.com
Ouch. I must have used old version of web2py than.
I always imported simplejson as "import simplejson as json" 
I totally forgot to replicate my setup before terminating my linode server.

Maybe you had simplejson installed in your old o.s., so you could simply import it directly.

You could do this instead:

>>> from serializers import json_parser as json

It tries json stdlib, then an installed simplejson, and as fallback the module included in contrib.

Niphlod

unread,
May 3, 2013, 2:31:48 PM5/3/13
to web...@googlegroups.com
a little correction..... serializers.py in trunk now "inverts" the order of imports
it tries simplejson (cause newer versions of simplejson as an external module are always faster than the standard json shipped with python from 2.6 on)
then uses json
then uses contrib.simplejson
However, if you want to be "uber-compatible" it's best to use always what Alan suggested (using serializers) so you can "lean" on the "smart-import" that it does by default.

Kenny Chung

unread,
May 3, 2013, 3:26:03 PM5/3/13
to web...@googlegroups.com
Great to know! Thank you

Reply all
Reply to author
Forward
0 new messages