Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89729
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: ImportError with pickle (Python 2.7.9), possibly platform dependent |
| Date | 2015-05-01 14:34 +0200 |
| Organization | None |
| References | <494551ca-532f-4d4d-aff0-a3932416c8f4@googlegroups.com> <mailman.108.1430354695.3680.python-list@python.org> <20a5c7bf-2163-4b7a-8495-30ce23239903@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11.1430483669.3347.python-list@python.org> (permalink) |
Ben Sizer wrote: > On Thursday, 30 April 2015 01:45:05 UTC+1, Chris Angelico wrote: >> On Thu, Apr 30, 2015 at 2:01 AM, Ben Sizer wrote: >> > 1) There clearly is a module named OMDBMap, and it's importable - it's >> > there in the 2nd line of the traceback. >> > >> > Does anybody have any suggestions on how I can go about debugging this? >> > Or refactoring it to avoid whatever is happening here? >> >> Are you half way through importing it when this load() call happens? >> That might cause some issues. > > No, we already imported OMDBMap at the top of OMDBSetup. > >> Has your current directory been changed anywhere in there? > > Good question. It turns out that the current directory seems to be $HOME > when loading, but is the script directory during saving. This will be > because the Linux server is running under mod_wsgi, whereas we run the > save script in-place. Our Windows and Mac tests run via Flask's built-in > server so the working directory is likely to be the same whether we're > running the script that does pickle.dump or the whole app that does > pickle.load. > >> What happens if you catch this exception and print out sys.modules at >> that point? > > Another good question, and this gives us the answer. The module lists are > quite different, as I'd expect because the load happens in the context of > the full application whereas the dump happens as a standalone script. But > literally every module that is in the 'before dump' list is in the 'before > load' list - except OMDBMap. Like the error says! What /is/ in the 'before > load' list however is "my_wsgi_app.OMDBMap". The module has been imported, > but the pickle algorithm is unable to reconcile the module in the WSGI > app's namespace with the module referenced in the pickle file. > > So... I don't know how to fix this, but I do now know why it fails, and I > have a satisfactory answer for why it is acting differently on the Linux > server (and that is just because that is the only one running under WSGI). > Two out of three isn't bad! How about moving OMDBMap.py into the parent folder of my_wsgi_app.__file__ or any other folder in sys.path?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-04-29 09:01 -0700
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Chris Angelico <rosuav@gmail.com> - 2015-04-30 10:44 +1000
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-01 04:01 -0700
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Chris Angelico <rosuav@gmail.com> - 2015-05-01 22:09 +1000
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-13 03:23 -0700
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Peter Otten <__peter__@web.de> - 2015-05-01 14:34 +0200
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-13 03:27 -0700
csiph-web