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

cannot import name 'asn1' from 'cryptography.hazmat.bindings._rust' #9633

Closed
Luancem opened this issue Sep 20, 2023 · 4 comments
Closed

cannot import name 'asn1' from 'cryptography.hazmat.bindings._rust' #9633

Luancem opened this issue Sep 20, 2023 · 4 comments
Labels
waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.

Comments

@Luancem
Copy link

Luancem commented Sep 20, 2023

hello,
I have installed jwt-1.3.0-py3-none-any.whl and cryptography-35.0.0-pp38-none-linux_x86_64.whl 。
But it reported below error when I "import jwt" 。 Could someone help me? Thanks very much!

[root@*** pypy3.10]# ../../bin/pypy3.10
Python 3.10.12 (af44d0b8114cb82c40a07bb9ee9c1ca8a1b3688c, Jun 15 2023, 12:39:27)
[PyPy 7.3.12 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import jwt
Traceback (most recent call last):
File "", line 1, in
File "///pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/jwt/init.py", line 17, in
from .jwa import std_hash_by_alg
File "///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/jwt/jwa.py", line 26, in
from cryptography.hazmat.primitives.asymmetric import padding
File "///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py", line 12, in
from cryptography.hazmat.primitives.asymmetric import rsa
File "", line 1078, in _handle_fromlist
File "", line 241, in _call_with_frames_removed
File "///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 15, in
from cryptography.hazmat.primitives.asymmetric import (
File "", line 1078, in _handle_fromlist
File "", line 241, in _call_with_frames_removed
File "///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py", line 6, in
from cryptography.hazmat.bindings._rust import asn1
ImportError: cannot import name 'asn1' from 'cryptography.hazmat.bindings._rust' (unknown location)

[root@*** pypy3.10]# ls site-packages/RUST
RUST/ RUST-1.3.1.dist-info/ RUST-1.3.1-py3-none-any.whl
[root@*** pypy3.10]# ls site-packages/cryptography
cryptography/ cryptography-35.0.0-pp38-none-linux_x86_64.whl
cryptography-35.0.0.dist-info/
[root@*** pypy3.10]# ls site-packages/jwt
jwt/ jwt-1.3.0.dist-info/ jwt-1.3.0-py3-none-any.whl

@alex
Copy link
Member

alex commented Sep 20, 2023

You appear to be using pypy 3.10, but have a pypy 3.8 wheel. How did you install cryptography?

@alex alex added the waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply. label Sep 20, 2023
@Luancem
Copy link
Author

Luancem commented Sep 21, 2023

Thanks alex for reply!
This is my installation steps.

root@*** site-packages]# ls cryptography-35.0*
cryptography-35.0.0-pp38-none-linux_x86_64.whl
[root@*** site-packages]#
[root@*** site-packages]#
[root@*** site-packages]# ../../../bin/pip3.8 install --no-index --find-links=///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages cryptography --target=/home/luance/pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/
Looking in links: ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages
Processing ./cryptography-35.0.0-pp38-none-linux_x86_64.whl
Processing ./cffi-1.15.0-py38-none-linux_x86_64.whl (from cryptography)
Processing ./pycparser-2.21-py2.py3-none-any.whl (from cffi>=1.12->cryptography)
Installing collected packages: pycparser, cffi, cryptography
Successfully installed cffi-1.15.0 cryptography-35.0.0 pycparser-2.21
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/pycparser already exists. Specify --upgrade to force replacement.
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/pycparser-2.21.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/_cffi_backend.cpython-310-x86_64-linux-gnu.so already exists. Specify --upgrade to force replacement.
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cffi already exists. Specify --upgrade to force replacement.
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cffi.libs already exists. Specify --upgrade to force replacement.
WARNING: Target directory ///pypy3.10/pypy3.10-v7.3.12-linux64/lib/pypy3.10/site-packages/cffi-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@*** site-packages]#

@reaperhulk
Copy link
Member

The pp38 wheel will not work with PyPy 3.10 as PyPy does not have a stable interface. You need a pp310 wheel. This will require you to use a newer version of cryptography that ships a wheel compatible with your PyPy or else compile it yourself.

@Luancem
Copy link
Author

Luancem commented Sep 21, 2023

Thanks very much. It works well after jwt1.3.1 and cryptography41.0.2 installation.

Thanks again!

@Luancem Luancem closed this as completed Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.
Development

No branches or pull requests

3 participants