Getting a circular import error

Everything builds fine, works on local, but once I try to deploy, I get this error. I’ve tried downgrading and updating dependencies, importing new ones, googling and duck duck go-ing around and I’m genuinely stuck.

Apr 19 01:46:05 PM  Package operations: 82 installs, 0 updates, 0 removals
Apr 19 01:46:05 PM  
Apr 19 01:46:05 PM    • Installing pyasn1 (0.4.8)
Apr 19 01:46:05 PM    • Installing pyparsing (3.0.8)
Apr 19 01:46:05 PM    • Installing six (1.16.0)
Apr 19 01:46:09 PM    • Installing httplib2 (0.20.4)
Apr 19 01:46:09 PM    • Installing protobuf (4.0.0rc2)
Apr 19 01:46:09 PM    • Installing pyasn1-modules (0.2.8)
Apr 19 01:46:09 PM    • Installing pycparser (2.21)
Apr 19 01:46:09 PM    • Installing rsa (4.8)
Apr 19 01:46:12 PM    • Installing cffi (1.15.0)
Apr 19 01:46:12 PM    • Installing future (0.18.2)
Apr 19 01:46:12 PM    • Installing googleapis-common-protos (1.56.0)
Apr 19 01:46:12 PM    • Installing grpcio (1.46.0rc1)
Apr 19 01:46:12 PM    • Installing oauth2client (4.1.3)
Apr 19 01:46:12 PM    • Installing ply (3.8)
Apr 19 01:46:12 PM    • Installing wcwidth (0.2.5)
Apr 19 01:46:12 PM    • Installing wrapt (1.14.0)
Apr 19 01:46:12 PM    • Installing vine (5.0.0)
Apr 19 01:46:20 PM    • Installing amqp (5.1.1)
Apr 19 01:46:20 PM    • Installing asgiref (3.5.0)
Apr 19 01:46:20 PM    • Installing certifi (2021.10.8)
Apr 19 01:46:20 PM    • Installing charset-normalizer (2.0.12)
Apr 19 01:46:20 PM    • Installing cachetools (5.0.0)
Apr 19 01:46:20 PM    • Installing click (8.1.2)
Apr 19 01:46:20 PM    • Installing google-gax (0.12.5)
Apr 19 01:46:20 PM    • Installing cryptography (36.0.2)
Apr 19 01:46:20 PM    • Installing grpc-google-pubsub-v1 (0.8.1)
Apr 19 01:46:20 PM    • Installing grpc-google-logging-v2 (0.8.1)
Apr 19 01:46:20 PM    • Installing deprecated (1.2.13)
Apr 19 01:46:20 PM    • Installing idna (3.3)
Apr 19 01:46:27 PM    • Installing prompt-toolkit (3.0.29)
Apr 19 01:46:27 PM    • Installing pytz (2022.1)
Apr 19 01:46:27 PM    • Installing sqlparse (0.4.2)
Apr 19 01:46:28 PM    • Installing urllib3 (1.26.9)
Apr 19 01:46:32 PM    • Installing async-timeout (4.0.2)
Apr 19 01:46:32 PM    • Installing billiard (3.6.4.0)
Apr 19 01:46:32 PM    • Installing click-didyoumean (0.3.0)
Apr 19 01:46:32 PM    • Installing click-repl (0.2.0)
Apr 19 01:46:32 PM    • Installing django (3.2.13)
Apr 19 01:46:32 PM    • Installing gax-google-pubsub-v1 (0.8.0)
Apr 19 01:46:32 PM    • Installing grpcio-status (1.45.0)
Apr 19 01:46:32 PM    • Installing click-plugins (1.1.1)
Apr 19 01:46:32 PM    • Installing gax-google-logging-v2 (0.8.3)
Apr 19 01:46:32 PM    • Installing jwcrypto (1.0)
Apr 19 01:46:32 PM    • Installing google-auth (2.6.5)
Apr 19 01:46:32 PM    • Installing defusedxml (0.7.1)
Apr 19 01:46:37 PM    • Installing kombu (5.2.4)
Apr 19 01:46:38 PM    • Installing oauthlib (3.2.0)
Apr 19 01:46:38 PM    • Installing packaging (21.3)
Apr 19 01:46:39 PM    • Installing python-dateutil (2.8.2)
Apr 19 01:46:39 PM    • Installing requests (2.27.1)
Apr 19 01:46:46 PM    • Installing celery (5.2.6)
Apr 19 01:46:46 PM    • Installing django-crispy-forms (1.14.0)
Apr 19 01:46:46 PM    • Installing django-timezone-field (4.2.3)
Apr 19 01:46:46 PM    • Installing djangorestframework (3.13.1)
Apr 19 01:46:46 PM    • Installing gcloud (0.18.3)
Apr 19 01:46:46 PM    • Installing google-api-core (2.7.2)
Apr 19 01:46:46 PM    • Installing grpc-google-iam-v1 (0.12.4)
Apr 19 01:46:46 PM    • Installing proto-plus (1.20.3)
Apr 19 01:46:46 PM    • Installing pyjwt (2.3.0)
Apr 19 01:46:46 PM    • Installing python-crontab (2.6.0)
Apr 19 01:46:46 PM    • Installing pycryptodome (3.14.1)
Apr 19 01:46:46 PM    • Installing python-jwt (3.3.2)
Apr 19 01:46:51 PM    • Installing python3-openid (3.2.0)
Apr 19 01:46:52 PM    • Installing redis (4.2.2)
Apr 19 01:46:52 PM    • Installing requests-oauthlib (1.3.1)
Apr 19 01:46:53 PM    • Installing requests-toolbelt (0.9.1)
Apr 19 01:46:59 PM    • Installing crispy-bootstrap5 (0.6)
Apr 19 01:46:59 PM    • Installing dj-database-url (0.5.0)
Apr 19 01:46:59 PM    • Installing django-allauth (0.50.0)
Apr 19 01:46:59 PM    • Installing django-anymail (8.5)
Apr 19 01:46:59 PM    • Installing django-celery-beat (2.2.1)
Apr 19 01:46:59 PM    • Installing django-debug-toolbar (3.2.4)
Apr 19 01:46:59 PM    • Installing django-cors-headers (3.11.0)
Apr 19 01:46:59 PM    • Installing django-extensions (3.1.5)
Apr 19 01:46:59 PM    • Installing django-redis (5.2.0)
Apr 19 01:46:59 PM    • Installing django-environ (0.8.1)
Apr 19 01:46:59 PM    • Installing django-hosts (5.1)
Apr 19 01:46:59 PM    • Installing django-rest-framework (0.1.0)
Apr 19 01:47:05 PM    • Installing google-cloud-pubsub (2.12.0)
Apr 19 01:47:05 PM    • Installing psycopg2 (2.9.3)
Apr 19 01:47:05 PM    • Installing pyrebase4 (4.5.0)
Apr 19 01:47:06 PM    • Installing whitenoise (6.0.0)

Apr 19 01:47:49 PM  ==> Uploading build...
Apr 19 01:48:00 PM  Traceback (most recent call last):  
File "/usr/bin/../lib/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 16, in <module>    
import bootstrapping  
File "/usr/lib/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", 
line 46, in <module>    from googlecloudsdk.core.updater import update_manager  
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/updater/update_manager.py", 
line 40, in <module>    from googlecloudsdk.core.resource import resource_printer  
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer.py", 
line 42, in <module>    from googlecloudsdk.core.resource import config_printer  
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/config_printer.py", line 25,
 in <module>    from googlecloudsdk.core.resource import resource_printer_base  
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer_base.py",
 line 47, in <module>    from googlecloudsdk.core.resource import resource_projector  
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_projector.py", 
line 71, in <module>    import proto  # pylint: disable=g-import-not-at-top  
File "/usr/lib/google-cloud-sdk/lib/third_party/proto/__init__.py", line 15, in <module>    
from .enums import Enum  File "/usr/lib/google-cloud-sdk/lib/third_party/proto/enums.py", 
line 17, in <module>    from google.protobuf import descriptor_pb2  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/protobuf/__init__.py", line 37, in <module>    __import__('pkg_resources').declare_namespace(__name__)  
File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 3031, in <module>    def _initialize_master_working_set():  File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 3014, in _call_aside    f(*args, **kwargs)  
File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 3056, in _initialize_master_working_set    tuple(  File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 3057, in <genexpr>    dist.activate(replace=False)  
File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 2588, in activate    declare_namespace(pkg)  
File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 2156, in declare_namespace    _handle_ns(packageName, path_item)  File "/usr/lib/google-cloud-sdk/lib/third_party/pkg_resources/__init__.py", line 2091, in _handle_ns    loader.load_module(packageName)  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub/__init__.py", line 18, in <module>    from google.pubsub_v1.services.publisher.async_client import PublisherAsyncClient  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/__init__.py", line 18, in <module>    from .services.publisher import PublisherClient  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/services/publisher/__init__.py", line 18, in <module>    from .client import PublisherClient  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/services/publisher/client.py", line 37, in <module>    from google.pubsub_v1.services.publisher import pagers  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/services/publisher/pagers.py", line 20, in <module>    from google.pubsub_v1.types import pubsub  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/types/__init__.py", line 18, in <module>    from .schema import (  
File "/usr/lib/google-cloud-sdk/lib/third_party/google/pubsub_v1/types/schema.py", line 21, in <module>    __protobuf__ = proto.module(AttributeError: partially initialized module 'proto' has no attribute 'module' (most likely due to a circular import)

Circular imports are generally caused by errors in the application code. Where Package A relies on Package B and Package B relies on Package A.

Can you make sure that you are using the same versions of your dependencies locally as are installed when you run it on Render?

Yes I can definitely check, do you have any suggestions on how to do it quickly? How do I check the dependencies in Render? My mind goes to the console.

Manually checked all the packages, the local and prod in Render match

Hi! Do you have a small reproduction github repo we can use to take a look through?

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