On my Windows 7 laptop I have both Python 2 and Python 3 installed, and I've been switching back and forth between them like py -2 myscript.py
etc.
I explicitly installed a package called pdfminer
by using pip2
and I've verified that it's on my disk at C:\Python27\Lib\site-packages\pdfminer
However, when I try to run a script I get an error:
> py -2 pdfminer.py
Traceback (most recent call last):
File "pdfminer.py", line 4, in <module>
from pdfminer.pdfparser import PDFParser
File "C:\Users\me\Documents\myprog\pdfminer.py", line 4, in <module>
from pdfminer.pdfparser import PDFParser
ImportError: No module named pdfparser
The import statement is exactly as given in the PDFMiner documentation, and I even added the Python 2 scripts directory explicitly to the PATH just in case that would help, but it didn't (I actually think that's redundant because from printing out sys.path
it seems it was already there):
import sys
sys.path.append("C:\Python27\Lib\site-packages\\")
from pdfminer.pdfparser import PDFParser
Within site-packages\pdfminer
there is a file pdfparser.py
and within it class PDFParser(PSStackParser)
. The case doesn't match the import statement, but actually making the import statement lowercase to match the file also doesn't help.
I don't really see anything wrong here. Is there anything else I could try?