Python Forum

Full Version: pdfminer package: module isn't found
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello,
In many examples of using of pdfminer, there are imports like this:
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
I installed pdfminer (version 20191125according to pip list).
But there is no pdfinterp inside pdfminer.
Any comments ?
Thanks
When I run the posted code I don't get any error messages. I also looked at the project page and saw there is a pdfinterp submodule.

What is the error message?
Do you get an import error if you "import pdfminer"? I have installed packages in the wrong Python in the past. Easy to do when you have multiple virtual environments.
(Sep-13-2022, 03:08 PM)deanhystad Wrote: [ -> ]When I run the posted code I don't get any error messages. I also looked at the project page and saw there is a pdfinterp submodule.

What is the error message?
Do you get an import error if you "import pdfminer"? I have installed packages in the wrong Python in the past. Easy to do when you have multiple virtual environments.
What is your pdfminer version ?

Output:
>>> from pdfminer.pdfinterp import PDFPageInterpreter Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from pdfminer.pdfinterp import PDFPageInterpreter ModuleNotFoundError: No module named 'pdfminer.pdfinterp' >>>
I am using pdfminer 20191125 with Python 3.9.0.

What does this print?
import pkgutil, pdfminer

for a, modname, c in pkgutil.walk_packages(path=pdfminer.__path__):
    print(modname)
I get this:
Output:
arcfour ascii85 ccitt cmapdb converter encodingdb fontmetrics glyphlist image latin_enc layout lzw pdfcolor pdfdevice pdfdocument pdffont pdfinterp pdfpage pdfparser pdftypes psparser rijndael runlength utils
(Sep-13-2022, 05:53 PM)deanhystad Wrote: [ -> ]I am using pdfminer 20191125 with Python 3.9.0.
What does this print?
import pkgutil, pdfminer
for a, modname, c in pkgutil.walk_packages(path=pdfminer.__path__):
    print(modname)

Output:
>>> import pkgutil, pdfminer >>> for a, modname, c in pkgutil.walk_packages(path=pdfminer.__path__): print(modname) rijndael >>>
You are not importing pdfminer. What do you see when you run this?
import pdfminer

print(pdfminer.__file__)
(Sep-13-2022, 06:45 PM)deanhystad Wrote: [ -> ]You are not importing pdfminer. What do you see when you run this?
import pdfminer

print(pdfminer.__file__)

Output:
>>> import pdfminer >>> print(pdfminer.__file__) Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> print(pdfminer.__file__) AttributeError: module 'pdfminer' has no attribute '__file__' >>>
How are you running this code? What Python are you using? Which OS? How do you run Python?
Look if have named a file pdfminer.py or folder,is a common mistake in these cases.
Do this.
>>> import pdfminer
>>> 
>>> dir(pdfminer)
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__']
So these are the specials methods in pdfminer.
If you see something else or nothing then you import a file/folder that is not pdfminer.
pdfinterp import the ordinary methods it has.
>> import pdfminer.pdfinterp
>>> 
>>> dir(pdfminer)
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 'arcfour',
 'ascii85',
 'ccitt',
 'cmapdb',
 'encodingdb',
 'fontmetrics',
 'glyphlist',
 'latin_enc',
 'lzw',
 'pdfcolor',
 'pdfdevice',
 'pdfdocument',
 'pdffont',
 'pdfinterp',
 'pdfpage',
 'pdfparser',
 'pdftypes',
 'psparser',
 'runlength',
 'settings',
 'utils']
A pdfminer.py somewhere in the path was what I was thinking, but what kind of file doesn't raise an import error and doesn't have a __file__ attribute? I cannot make that happen if I try.
Pages: 1 2 3