Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #89729

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.04; 'importing': 0.05; 'subject:Python': 0.06; 'context': 0.07; 'debugging': 0.07; 'differently': 0.07; 'here?': 0.09; 'imported': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'referenced': 0.09; 'question.': 0.14; 'windows': 0.15; 'different,': 0.16; 'dump': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'refactoring': 0.16; 'sys.modules': 0.16; 'there?': 0.16; 'traceback.': 0.16; 'wsgi': 0.16; 'exception': 0.16; 'folder': 0.16; 'thursday,': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'app': 0.19; 'module': 0.19; 'thu,': 0.19; 'seems': 0.21; 'tests': 0.22; 'print': 0.22; 'load': 0.23; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; 'script.': 0.24; 'file.': 0.24; 'script': 0.25; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'gives': 0.31; 'pickle': 0.31; 'lists': 0.32; "we're": 0.32; 'run': 0.32; 'another': 0.32; 'quite': 0.32; 'linux': 0.33; 'running': 0.33; 'mac': 0.33; "i'd": 0.34; 'subject: (': 0.35; 'subject:with': 0.35; 'anywhere': 0.35; 'except': 0.35; 'anybody': 0.35; 'no,': 0.35; 'but': 0.35; 'there': 0.35; 'half': 0.37; 'application': 0.37; 'two': 0.37; 'list': 0.37; 'server': 0.38; 'ben': 0.38; 'question,': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'does': 0.39; 'moving': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'unable': 0.39; 'received:org': 0.40; 'how': 0.40; '2nd': 0.60; 'catch': 0.60; 'full': 0.61; 'save': 0.62; 'our': 0.64; '30,': 0.65; 'answer.': 0.68; '2015': 0.84; 'fails,': 0.84; 'so...': 0.84; 'whereas': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: ImportError with pickle (Python 2.7.9), possibly platform dependent
Date Fri, 01 May 2015 14:34:13 +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>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd85d4.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11.1430483669.3347.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430483669 news.xs4all.nl 2894 [2001:888:2000:d::a6]:35932
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:89729

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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