Forums

Issue with web2py app: "Can not import copy_reg"

I am hosting my Web2py app on PA and have an issue that web2py comes with an error when importing copy_reg which web2py apparently needs. In previous versions this was no issue. I can import copy_reg from the python2.7 prompt.

The trace back is as follows: Traceback (most recent call last):

File "/home/richdijk/web2py/gluon/restricted.py", line 220, in restricted
  exec ccode in environment
File "/home/richdijk/web2py/applications/im/models/db.py", line 78, in <module>
  auth.define_tables(username=False, signature=False)
File "/home/richdijk/web2py/gluon/tools.py", line 1784, in define_tables
   format='%(first_name)s %(last_name)s (%(id)s)'))
File "/home/richdijk/web2py/gluon/dal.py", line 8223, in define_table
   table = self.lazy_define_table(tablename,*fields,**args)
File "/home/richdijk/web2py/gluon/dal.py", line 8260, in lazy_define_table
   polymodel=polymodel)
File "/home/richdijk/web2py/gluon/dal.py", line 1122, in create_table
  sql_fields_old = pickle.load(tfile)
File "/home/richdijk/web2py/gluon/custom_import.py", line 92, in custom_importer
   return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named copy_reg

Does anybody have a resolution for this? Thank you

btw, I try to use the web2py debugger for checking import of copy_reg from the web2py console, but the debugger seems to 'hang' . Should it work?

That's odd, copy_reg is a standard part of the Python library. Just to make sure, you are using Python 2.7 rather than 3.x, right? I would expect web2py to fail completely on 3.x, before it even managed to get this far, but just in case...

I am really running on 2.7. But I have this issue on all hosting platforms....including Apache/CGI. For this I try to reach Massimo to report it as a bug, but no reaction from there, possibly on a wel deserved holiday. I was wondering whether other web2py designer did have this issue.

That's definitely really weird. PythonAnywhere is running nginx/uWSGI, so it's certainly not an Apache/CGI problem.

Did you hear anything back from Massimo or other web2py developers at all?

In the beginning yes, not any more: https://groups.google.com/forum/#!topic/web2py/8toVDprfqwM

I see. It's definitely very odd. I'll post to that list too, perhaps I can provide more information that might help them track it down.

So, one suggestion in the web2py group is that you might have something pickled from a different version of Python... might that be the problem?

Leonel Câmara wrote:

My guess would be this is happening because of you copying files with pickles around. Some stuff is not portable, for instance, web2py uses marshal in some places.

Pickle is infamous for giving very weird error messages like the one you are getting that appear to point to other problems.

If I am right, a solution can be to delete everything with pickles on it. Like the table files in the database folder, the sessions and everything in the cache.

Giles,

I updated the web2py group thread https://groups.google.com/forum/#!topic/web2py/8toVDprfqwM Thank for the support. I am only using PA for 1 day, I like it :)

Richard

:)