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

Cryptography cant find file. #960

Open
mdevore300 opened this issue Aug 9, 2023 · 5 comments
Open

Cryptography cant find file. #960

mdevore300 opened this issue Aug 9, 2023 · 5 comments
Labels

Comments

@mdevore300
Copy link

Describe the bug

It can't find a file in the cryptography program. Import Cryptography on its own works fine.

Have you tried repairing the PDF?

No as I can't even import pdfplumber

Code to reproduce the problem

So, i've updated all dependencies finally. Still getting the same error. So all i was trying to do was in spyder, import pdfplumber so i could run a script. So I highlighted import pdfplumber, then hit F9
The full traceback is as follows:

File "", line 1, in
import pdfplumber

File "C:\ProgramData\Anaconda3\lib\site-packages\pdfplumber_init_.py", line 14, in
for .pdf import PDF

File "C:\ProgramData\Anaconda3\lib\site-packages\pdfplumber\pdf.py, line 8, in
from pdfminer.layour import LAParams

File "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\layout.py", line 20, in
from .pdfinterp import Color

File "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\pdfinterp.py", line 12, in
from .pdfdevice import PDFDevice

FIle "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\pdfdevice.py," line 17, in
from .pdfpage import PDFPage

FIle "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\pdfpage.py," line 7, in
from .pdfdocument import PDFDocument, PDFTextExtractionNotAllowed, PDFNoPageLabels

FIle "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\pdfdocument.py", line 23, in
from cryptography.hazmat.preimitives.cipher import Cipher, algorithms, modes

FIle "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\primitives\ciphers_init_.py", line 11, in
from cryptography.hazmat.primitives.ciphers.base import (

FIle "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\primitives\ciphers\base.py", line 10, in
from cryptography.exceptions.import (

FIle "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\exceptions.py", line 9, in
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions

ImportError: cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust (unknown location)

Environment

  • pdfplumber version: latest
  • Python version: 3.8.1
  • Windows

Additional context

Add any other context/notes about the problem here.

@mdevore300 mdevore300 added the bug label Aug 9, 2023
@cmdlineluser
Copy link

Hi mdevore300

If you look at the traceback, the error is coming from pdfminer trying to load cryptography (pdfplumber uses pdfminer).

Import Cryptography on its own works fine.

Not too familiar with spyder or anaconda but the first step I'd try would be to run the actual offending line in isolation inside a minimal environment (which appears to be an "Anaconda Prompt" session?) to try figure out where the problem is.

from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions

@mdevore300
Copy link
Author

Okay, I will have to try it on Tuesday and see if there is still an error.

@mdevore300
Copy link
Author

so i tried
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
it as a standalone and it gave the same error.

cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location).

@cmdlineluser
Copy link

Yes, that suggests your cryptography installation is somehow "broken".

Not used anaconda, but it looks like the next step in debugging would be creating a fresh environment and seeing if the issue persists.

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands

# 4. To create an environment with a specific package:

conda create -n myenv cryptography

@yang162132
Copy link

You can try
conda install cryptography -c conda-forge

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

3 participants