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

Incompatibility issue when upgrading PyJWT >= 2.0.0 by any other package #628

Closed
muhammad-mamdouh opened this issue Nov 3, 2021 · 4 comments

Comments

@muhammad-mamdouh
Copy link

When installing any package with PyJWT >= 2.0.0 the server crashes as the django-push-notifications require PyJWT < 2.0.0

Traceback:

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Users/anon/.pyenv/versions/3.9.0/lib/python3.9/threading.py", line 950, in _bootstrap_inner
    self.run()
  File "/Users/anon/.pyenv/versions/3.9.0/lib/python3.9/threading.py", line 888, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/django/apps/config.py", line 224, in create
    import_module(entry)
  File "/Users/anon/.pyenv/versions/3.9.0/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/push_notifications/__init__.py", line 4, in <module>
    __version__ = pkg_resources.require("django-push-notifications")[0].version
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 886, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 777, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (PyJWT 2.3.0 (/Users/anon/.virtualenvs/venv/lib/python3.9/site-packages), Requirement.parse('PyJWT<2.0.0,>=1.4.0'), {'apns2'})
@auvipy
Copy link

auvipy commented Nov 3, 2021

that package needed to be adjusted IMHO

@muhammad-mamdouh
Copy link
Author

@auvipy I figured out now that the problem mainly at the apns2 package and actually its updated there but the maintainer didn't release the master update now.

Pr0Ger/PyAPNs2#133

@nik13
Copy link

nik13 commented Nov 7, 2021

this is because the package is not updated on pip. Use github master branch to install the lastest package

@auvipy auvipy closed this as completed Nov 10, 2021
@madhavSoni
Copy link

madhavSoni commented Apr 4, 2022

Was anyone able to get this to work? I get this issue when I used the latest commit

apns2 @ git+https://github.com/Pr0Ger/PyAPNs2.git@910780bb909c85ffd40f8d2cd517b764c4576253
PyJWT==2.3.0
django-push-notifications==3.0.0

[03/Apr/2022 19:00:54] "PUT /api/changeTransactionStatus/fdf8c2fd-c937-475a-960f-9d8b862db492/ HTTP/1.1" 200 13966
Traceback (most recent call last):
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 183, in finish_response
    self.close()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 114, in close
    super().close()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/simple_server.py", line 38, in close
    SimpleHandler.close(self)
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 321, in close
    self.result.close()
  File "/Users/madhavsoni/Documents/BazarBackend/bazar_backend/api/views/TransactionViews/TransactionView.py", line 168, in close
    self.then_callback()
  File "/Users/madhavsoni/Documents/BazarBackend/bazar_backend/api/views/TransactionViews/TransactionView.py", line 232, in send_push_notification
    badge=lambda token: APNSDevice.objects.get(
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/models.py", line 136, in send_message
    creds=creds, **kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/apns.py", line 154, in apns_send_bulk_message
    creds=creds, **kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/apns.py", line 103, in _apns_send
    **notification_kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/client.py", line 203, in send_notification_batch
    priority, expiration, collapse_id, push_type)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/client.py", line 141, in send_notification_async
    auth_header = self.__credentials.get_authorization_header(topic)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/credentials.py", line 60, in get_authorization_header
    token = self._get_or_create_topic_token()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/credentials.py", line 90, in _get_or_create_topic_token
    headers=headers)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/api_jwt.py", line 63, in encode
    return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/api_jws.py", line 113, in encode
    key = alg_obj.prepare_key(key)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/algorithms.py", line 416, in prepare_key
    key = load_pem_public_key(key)
TypeError: load_pem_public_key() missing 1 required positional argument: 'backend'
[03/Apr/2022 19:00:55] "PUT /api/changeTransactionStatus/fdf8c2fd-c937-475a-960f-9d8b862db492/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51618)
Traceback (most recent call last):
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 183, in finish_response
    self.close()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 114, in close
    super().close()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/simple_server.py", line 38, in close
    SimpleHandler.close(self)
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 321, in close
    self.result.close()
  File "/Users/madhavsoni/Documents/BazarBackend/bazar_backend/api/views/TransactionViews/TransactionView.py", line 168, in close
    self.then_callback()
  File "/Users/madhavsoni/Documents/BazarBackend/bazar_backend/api/views/TransactionViews/TransactionView.py", line 232, in send_push_notification
    badge=lambda token: APNSDevice.objects.get(
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/models.py", line 136, in send_message
    creds=creds, **kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/apns.py", line 154, in apns_send_bulk_message
    creds=creds, **kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/push_notifications/apns.py", line 103, in _apns_send
    **notification_kwargs
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/client.py", line 203, in send_notification_batch
    priority, expiration, collapse_id, push_type)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/client.py", line 141, in send_notification_async
    auth_header = self.__credentials.get_authorization_header(topic)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/credentials.py", line 60, in get_authorization_header
    token = self._get_or_create_topic_token()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/apns2/credentials.py", line 90, in _get_or_create_topic_token
    headers=headers)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/api_jwt.py", line 63, in encode
    return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/api_jws.py", line 113, in encode
    key = alg_obj.prepare_key(key)
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/jwt/algorithms.py", line 416, in prepare_key
    key = load_pem_public_key(key)
TypeError: load_pem_public_key() missing 1 required positional argument: 'backend'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 119, in handle_error
    super().handle_error()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 174, in handle
    self.handle_one_request()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 197, in handle_one_request
    handler.run(self.server.get_app())
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/Users/madhavsoni/eb-virt/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 114, in close
    super().close()
  File "/Users/madhavsoni/.pyenv/versions/3.7.2/lib/python3.7/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

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

4 participants