4

Whenever I use pdf2txt.py on my command line the source file opens and the command does not execute. I've just installed the packages and haven't been able to get it to run. For example, I will type the command:

pdf2txt.py -c UTF-8 output.txt "my file.pdf"

after typing the command, the file pdf2txt.py will open and the command won't execute. Has anyone encountered this before? What am I doing wrong?

I'm using windows command prompt. Any help would be greatly appreciated.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
user3368835
  • 357
  • 2
  • 7
  • 15

1 Answers1

3

You need to run it as

python pdf2txt.py -c UTF-8 output.txt "my file.pdf

Windows doesn't use the !# syntax, I think.

Akshat Harit
  • 814
  • 1
  • 7
  • 13
  • 1
    When I tried that it says that "can't open file 'pdf2txt.py': [Errno2] No such file or directory" – user3368835 Jul 22 '15 at 21:57
  • 4
    did you provide the full path to the file? `python path/to/pdf2txt.py`? – letsc Jul 22 '15 at 22:00
  • I did not. I just did and it worked! thanks so much! – user3368835 Jul 22 '15 at 22:40
  • No he doesn't have to run it as python pdf2txt,py if he doesn't want to! 1. Windows doesn't use the execution line on top of scripts but uses extensions and will start python automatically. 2. Python installer doesn't add Python to the %PATH% environment variable, so typing only python into prompt will produce an error. C:\Python27\python.exe pdf2txt.py or similar would work though. – Dalen Jul 22 '15 at 22:41
  • If you run in some more trouble, have in mind that there are some slightly backward incompatible pdfminer versions. I had a problem with pdf2txt that used the older pdfminer and it didn't work with my version. – Dalen Jul 22 '15 at 22:48
  • @Dalen It is common(at least in people i know) to associate .py files with text editors for devs. Hence, I didn't mention it. However, you are right. Windows uses extensions for detecting what program for call for execution. – Akshat Harit Jul 22 '15 at 22:52
  • @Akshat I would never do that. I am using Open with to get to the source, and not closing the file while developing. I'ts obvious that Anony has custom install, because Python installer associates *.py with the interpreter by default. At least Python 2.x installer did. – Dalen Jul 23 '15 at 06:36
  • I mean, when first time I accidentally ommited the interpreter on Windows I received a slight shock when thing worked. I mean, it's alright for clicking but as you get used to on Unixes that console does what you tell it and no more or less it was still a surprise. – Dalen Jul 23 '15 at 06:44