Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PDFMiner install question

773 views
Skip to first unread message

Jason Mellone

unread,
Dec 17, 2013, 3:06:54 PM12/17/13
to
Hello,

I have python up and running using the exact setup as recommended by http://learnpythonthehardway.org/

I am now trying to use pdfminer.

I have python here:
C:\USERS\Python27

using "import os", i am able to cwd to C:\users\python where i have C:\users\python\pdfminer-master\.

when i navigate to the child directory and run "setup.py install" i get the following issue:

>>> setup.py install
File "<stdin>", line 1
setup.py install
^

i have no idea why, any input?

thanks!

Mark Lawrence

unread,
Dec 17, 2013, 3:27:50 PM12/17/13
to pytho...@python.org
The "import os" tells me that you're running setup.py from a Python
prompt, you should be running it from a Windows command prompt.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

MRAB

unread,
Dec 17, 2013, 3:32:56 PM12/17/13
to pytho...@python.org
On 17/12/2013 20:06, Jason Mellone wrote:
Do you really have the ">>>" prompt? If yes, then you're asking Python
to run a console (OS) command.

You should be running "setup.py install" in a console ("Command
Prompt") window, something like:

cd C:\users\python\pdfminer-master
C:\USERS\Python27\python.exe \setup.py install

Jason Mellone

unread,
Dec 17, 2013, 3:53:24 PM12/17/13
to
ok makes sense.

i am running now from command line and get the following:

P:\>C:\USERS\Python27\python.exe C:\users\Python27\pdfminer-master\setup.py inst
all
running install
running build
running build_py
error: package directory 'pdfminer' does not exist

P:\>



Jason Mellone

unread,
Dec 17, 2013, 3:59:22 PM12/17/13
to
also this is my dir:
P:\>dir C:\users\python27\pdfminer-master
Volume in drive C has no label.
Volume Serial Number is B825-02BA

Directory of C:\users\python27\pdfminer-master

17/12/2013 02:55 PM <DIR> .
17/12/2013 02:55 PM <DIR> ..
17/12/2013 02:48 PM <DIR> cmaprsrc
17/12/2013 02:48 PM <DIR> docs
26/11/2013 04:35 AM 1,723 Makefile
26/11/2013 04:35 AM 111 MANIFEST.in
17/12/2013 03:49 PM <DIR> pdfminer
26/11/2013 04:35 AM 5,311 README.md
17/12/2013 02:48 PM <DIR> samples
26/11/2013 04:35 AM 1,384 setup.py
17/12/2013 02:48 PM <DIR> tools
4 File(s) 8,529 bytes
7 Dir(s) 26,006,282,240 bytes free

P:\>

Mark Lawrence

unread,
Dec 17, 2013, 5:03:37 PM12/17/13
to pytho...@python.org
Hi, glad to see you're making some progress :) You're likely to get
more offers of assistance if you read and action this
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the
double line spacing above, thanks.

MRAB

unread,
Dec 17, 2013, 6:30:16 PM12/17/13
to pytho...@python.org
On 17/12/2013 20:59, Jason Mellone wrote:> On Tuesday, December 17, 2013
The prompt shows that the current directory is P:\.

On Windows, each drive has its own current directory, so you have to
set the default drive too.

I think this should do it:

C:
cd C:\users\Python27\pdfminer-master

Jason Mellone

unread,
Dec 19, 2013, 2:36:49 PM12/19/13
to
MRAB: Thank you your exact solution worked perfectly.

Now I am trying to run some code from (http://www.unixuser.org/~euske/python/pdfminer/programming.html) under basic usage.

If I try to run
<code>
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfpage import PDFTextExtractionNotAllowed
from pdfminer.pdfinterp import PDFResourceManager
from pdfminer.pdfinterp import PDFPageInterpreter
from pdfminer.pdfdevice import PDFDevice

# Open a PDF file.
fp = open('C:\\USERS\\Python27\\samples\\test.pdf', 'rb')
# Create a PDF parser object associated with the file object.
parser = PDFParser(fp)
# Create a PDF document object that stores the document structure.
document = PDFDocument(parser)

print "done"
</code>


I get the following error:
PS C:\USERS\Python27> .\python.exe .\MyTest.py
Traceback (most recent call last):
File ".\MyTest.py", line 4, in <module>
from pdfminer.pdfpage import PDFTextExtractionNotAllowed
ImportError: cannot import name PDFTextExtractionNotAllowed


If I run commenting out the import of "PDFTextExtractionNotAllowed" it runs without a problem. Quite odd.

MRAB

unread,
Dec 19, 2013, 4:18:39 PM12/19/13
to pytho...@python.org
A quick Google tokk me here:

http://css.dzone.com/articles/pdf-reading

Its example contains:

from pdfminer.pdfinterp import PDFResourceManager,
PDFPageInterpreter, PDFTextExtractionNotAllowed

Note how it's importing PDFTextExtractionNotAllowed from a different
place.

Perhaps the author of the code you're looking at didn't test it. It
happens! :-)

Andreas Perstinger

unread,
Dec 20, 2013, 4:00:52 AM12/20/13
to pytho...@python.org
Jason Mellone <jason....@gmail.com> wrote:
>I get the following error:
>PS C:\USERS\Python27> .\python.exe .\MyTest.py
>Traceback (most recent call last):
> File ".\MyTest.py", line 4, in <module>
> from pdfminer.pdfpage import PDFTextExtractionNotAllowed
>ImportError: cannot import name PDFTextExtractionNotAllowed
>
>
>If I run commenting out the import of "PDFTextExtractionNotAllowed" it
>runs without a problem. Quite odd.

According to the latest version on Github,
"PDFTextExtractionNotAllowed" was moved into the "PDFPage" class, but
the sample code in the docs was obviously not updated.

https://github.com/euske/pdfminer/blob/master/pdfminer/pdfpage.py

So just leave out that line and if you need that exception use
"PDFPage.PDFTextExtractionNotAllowed" instead of
"PDFTextExtractionNotAllowed".

Bye, Andreas
0 new messages