jsvine / pdfplumber

Plumb a PDF for detailed information about each char, rectangle, line, et cetera — and easily extract text and tables.
MIT License
6.02k stars 619 forks source link

Cryptography cant find file. #960

Open mdevore300 opened 11 months ago

mdevore300 commented 11 months ago

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\pdfplumberinit.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\ciphersinit.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

Additional context

Add any other context/notes about the problem here.

cmdlineluser commented 11 months ago

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 commented 11 months ago

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

mdevore300 commented 11 months ago

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 commented 11 months ago

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 commented 4 months ago

You can try conda install cryptography -c conda-forge