Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.4.2: ImportError: cannot import name 'context' (cyclic import?) #73

Closed
jeroenmeulenaar opened this issue Feb 9, 2018 · 4 comments
Assignees

Comments

@jeroenmeulenaar
Copy link

Steps to reproduce:

What happens:

~ $ python3 test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from bunq.sdk import context
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/context.py", line 9, in <module>
    from bunq.sdk.model.generated import endpoint
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/model/generated/endpoint.py", line 3, in <module>
    from bunq.sdk import context
ImportError: cannot import name 'context'

It looks like a cyclic import (`context` importing `endpoint` and `endpoint` importing `context`), but I don't know why this is a problem for python 3.4.2.
@jeroenmeulenaar
Copy link
Author

I now used pyenv to install 3.6.3 locally, and then this issue does not occur.

@jeroenmeulenaar
Copy link
Author

And already in python version 3.5.5 this passes, but I can't find anything in the 3.5.5 release notes that would explain this.

@OGKevin
Copy link
Contributor

OGKevin commented Feb 13, 2018

Oh boy, is this related to #72 ? I think we need to bump the minimum required python version. The structure the SDK has no can indeed cause for circular dependencies. In early development we also suffered from this. Instead of importing the class directly we import the module. This seems to work fine and the latest version of python3 which was 3.6 at that time. We didn't test on lower versions of python3 🤦‍♂️.

@jeroenmeulenaar
Copy link
Author

It's not directly related to #72, but they are both about issues running code on python version below python 3.6.

I found the change: it's in version 3.5.0. The release notes at https://docs.python.org/3.5/whatsnew/3.5.html write

Circular imports involving relative imports are now supported. (Contributed by Brett Cannon and Antoine Pitrou in bpo-17636.)

I guess this quite some work to fix (use only import foo instead of using from foo import bar). I'll just stick with pyenv; you can increase the minimum required python version to 3.5.

@OGKevin OGKevin self-assigned this Apr 8, 2018
@OGKevin OGKevin added this to the 0.13.5 milestone Apr 8, 2018
OGKevin added a commit that referenced this issue Apr 12, 2018
OGKevin added a commit that referenced this issue May 1, 2018
@OGKevin OGKevin closed this as completed May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants