Neha Narang
Neha Narang

Reputation: 261

Import error : cannot import name 'open_filename' from 'pdfminer.utils'

On importing pdfminer.high_level, I am getting an error cannot import name open_filename from pdfminer.utils.

I tried following steps:

  1. pip3 install pdfminer.six
  2. import pdfminer
  3. import pdfminer.high_level

(and encountered error on this line)


ImportError                               Traceback (most recent call last)
<ipython-input-6-772e4980255d> in <module>
----> 1 import pdfminer.high_level

~\anaconda3\lib\site-packages\pdfminer\high_level.py in <module>
     12 from .pdfinterp import PDFResourceManager, PDFPageInterpreter
     13 from .pdfpage import PDFPage
---> 14 from .utils import open_filename
     15 
     16 

ImportError: cannot import name 'open_filename' from 'pdfminer.utils'

Upvotes: 26

Views: 36358

Answers (4)

ROSHAN KUMAR
ROSHAN KUMAR

Reputation: 51

First Uninstall the pdfminer.six

pip3 uninstall pdfminer.six

Then re install

pip3 install pdfminer.six

It has solved my problem.

Upvotes: 5

Manoj Mohan
Manoj Mohan

Reputation: 6044

I had an older version of pdfminer.six. This is the commit that introduced the open_filename method. Make sure your pdfminer.six version is greater than '20200402'.

Upvotes: 0

user3475645
user3475645

Reputation:

I faced a similar problem: cannot import name 'open_filename' from 'pdfminer.utils' when using the langchain cookbook. Problem was python v.3.11x. I downgraded my env to 3.8.18 and it worked.

Upvotes: 3

Ines ben youssef
Ines ben youssef

Reputation: 491

Hi I had the same issue.

I had installed both pdfminer and pdfminer.six. Please keep pdfminer.six and uninstall pdfminer with:

pip uninstall pdfminer

Upvotes: 38

Related Questions