Deleted .py file causing builds to fail when using cache in python project


I had a file in a certain directory in the past, which was renamed.
If that file exists, the build fails, as the “proper” exists in a separate directory.
Somehow it seems that a “zombie” version (in python those are usually .pyc files) of that file is there as I get an import error when running the tests:

  File "/root/delta/transfers/", line 8, in <module>
    from models import Account
ImportError: cannot import name Account

I am certain the Account class exists in in the “proper”, as rebuilding disabling cache results in a successful build.

I already tried changing my requirements.txt which forces a new cache to be created, but the problem somehow returned after a few builds.

The file is not in any of the directories that are cached, so it shouldn’t affect the cache of future builds.

Is there a way I can guarantee there’s no .pyc files from previous builds in the container running my builds?


The problem was indeed in our code.

cannot import name Account

was actually referring to a cyclic dependency, which is a bug in our code.
The weird thing is that depending on the thread order the bug would sometimes not happen.
And when running the tests locally the bug would never happen.
Anyway, once I was able to reproduce the problem locally, it was an easy fix.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.