Posts: 215
Threads: 55
Joined: Sep 2019
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
Posts: 6,780
Threads: 20
Joined: Feb 2020
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.
Posts: 215
Threads: 55
Joined: Sep 2019
Sep-13-2022, 04:57 PM
(This post was last modified: Sep-13-2022, 04:57 PM by Pavel_47.)
(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'
>>>
Posts: 6,780
Threads: 20
Joined: Feb 2020
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
Posts: 215
Threads: 55
Joined: Sep 2019
(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
>>>
Posts: 6,780
Threads: 20
Joined: Feb 2020
Sep-13-2022, 06:45 PM
(This post was last modified: Sep-13-2022, 06:45 PM by deanhystad.)
You are not importing pdfminer. What do you see when you run this?
import pdfminer
print(pdfminer.__file__)
Posts: 215
Threads: 55
Joined: Sep 2019
(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__'
>>>
Posts: 6,780
Threads: 20
Joined: Feb 2020
How are you running this code? What Python are you using? Which OS? How do you run Python?
Posts: 7,313
Threads: 123
Joined: Sep 2016
Sep-13-2022, 07:57 PM
(This post was last modified: Sep-13-2022, 07:57 PM by snippsat.)
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']
Posts: 6,780
Threads: 20
Joined: Feb 2020
Sep-13-2022, 08:03 PM
(This post was last modified: Sep-13-2022, 08:03 PM by deanhystad.)
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.
|