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

When installing for the first time and running migrate: AttributeError: module 'stripe' has no attribute 'Order' #2039

Closed
dunctk opened this issue Apr 15, 2024 · 6 comments
Labels

Comments

@dunctk
Copy link

dunctk commented Apr 15, 2024

Describe the bug
When trying to install dj-stripe, running migrate causes the following error:

python manage.py migrate
Loading environment variables for .env file
Traceback (most recent call last):
  File "/media/dunc/data/Code/contentmarketingexamples/manage.py", line 34, in <module>
    main()
  File "/media/dunc/data/Code/contentmarketingexamples/manage.py", line 30, in main
    execute_from_command_line(sys.argv)
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/djstripe/models/__init__.py", line 45, in <module>
    from .orders import Order
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/djstripe/models/orders.py", line 15, in <module>
    class Order(StripeModel):
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/djstripe/models/orders.py", line 24, in Order
    stripe_class = stripe.Order
                   ^^^^^^^^^^^^
  File "/media/dunc/data/Code/contentmarketingexamples/venv/lib/python3.11/site-packages/stripe/__init__.py", line 199, in __getattr__
    raise AttributeError(
AttributeError: module 'stripe' has no attribute 'Order'

To Reproduce
run python manage.py migrate

Software versions

  • Dj-Stripe version: 2.7.2
  • Python version: 3.11
  • Django version: 4.2.7
  • Stripe API version: 2024-04-10
  • Database type and version: Postgres
@dunctk dunctk added the bug label Apr 15, 2024
@pmdevita
Copy link

Stripe SDK is probably too new #1842

On a related note, is there a plan in place to deprecate Order and update the SDK?

@jleclanche
Copy link
Member

@pmdevita yes this will be fixed in djstripe 2.9. I've decided to release an additional intermediate release before 3.0...

@agusmakmun
Copy link

Hello @dunctk, yes, it's stripe SDK, and already discussed here #1842 (comment)

I'm facing the same issue, and solved by installing this version:

stripe>=4.0.0,<5.0.0

@jleclanche
Copy link
Member

This is fixed in 2.9.0a1 which was released recently, please test that release (note: it has not been tested in production yet, please create issues with all feedback).

@dunctk
Copy link
Author

dunctk commented May 24, 2024

Hello @dunctk, yes, it's stripe SDK, and already discussed here #1842 (comment)

I'm facing the same issue, and solved by installing this version:

stripe>=4.0.0,<5.0.0

Isn't Stripe on version 9 now? Is it a problem to be 4 versions behind?

@jleclanche
Copy link
Member

@dunctk it's not a real problem to be honest, the sdk just gives better access to newer stripe features but they have a very rigid backwards compatibility built into their api so the older SDKs work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants