importerror - Python Circular Import - Works locally but not on server -


background information

  • python 2.7.1 (r271:86832) on server , locally
  • using virtualenv dependencies same
  • local python 64 bit
  • server python 32 bit
  • using django

actual problem

we hit circular import problem on our server wasn't caught during testing.

doing trivial circular import example shows circular imports indeed erroring locally.

we stuck prints @ top of each file gets imported.

local behaviour:

priority.__init__.py sync.tasks.keywords.py priority.reasons.py priority.__init__.py (<- circular import works??) priority.reasons.py 

server behaviour:

priority.__init__.py sync.tasks.keywords.py priority.__init__.py (<- circular import works??) traceback (most recent call last):     ...     sync.tasks.keywords import check_keywords     importerror: cannot import name check_keywords 

i'm baffled. code same. i'm double baffled fact import chain different before erroring well.

so... tips on start looking?

i suggest break circular import moving 1 of imports inside classes/functions (instead of top of file). in opinion method doesn't have serious drawbacks , saves quite lot of time of hard , pretty useless debugging of circular imports.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -