Search code examples
pythondjangopyc

Issue with .pyc files on remote server


I had a Django project in which I had a file named itemA.py. Then I deleted that file and instead created a foldern with an identical name in which I placed files. So the new structure looked something like this:

itemA
   itemB.py
   itemC.py
   ...

Before that change, when itemA was a file, it contained a definition for a serializer which was imported elsewhere.

So after the change, when I ran the project on my local PC, I ran into an error saying:

ImportError: No module named 'rest_main.serializers.sms'; 'rest_main.serializers' is not a package

On my local PC, I fixed the issue instantly removing the itemA.pyc file. But when I pushed the changes to the remote server, the same trick did not help. I also ran the find . -name "*.pyc" -exec rm -f {} \; command. But still no success...In bitbucket, all the pyc files are under gitignore...


Solution

  • add a file called __init__.py to you folder

    this tells python that the folder is importable