天天看點

php調用Python找不到子產品,從php調用python腳本不導入所需子產品

我調用了一個在php中使用的python腳本$text = shell_exec("python import pdf2txt; parser_py/cv_parser.py -i '".$filepath."' 2>&1");

注意$filepath已經在前面聲明了,這不是問題。在

這是python腳本

^{pr2}$

textract導入其他子產品,當我運作php時,它們會失敗,但是當我運作終端時,它們工作得很好。這是下面的錯誤string(1635) "Traceback (most recent call last):

File "parser_py/cv_parser.py", line 39, in

main(sys.argv[1:])

File "parser_py/cv_parser.py", line 32, in main

print textract.process(arg)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/textract-1.4.0-py2.7.egg/textract/parsers/__init__.py", line 57, in process

return parser.process(filename, encoding, **kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/textract-1.4.0-py2.7.egg/textract/parsers/utils.py", line 44, in process

byte_string = self.extract(filename, **kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/textract-1.4.0-py2.7.egg/textract/parsers/pdf_parser.py", line 25, in extract

return self.extract_pdfminer(filename, **kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/textract-1.4.0-py2.7.egg/textract/parsers/pdf_parser.py", line 49, in extract_pdfminer

stdout, _ = self.run('pdf2txt.py "%(filename)s"' % locals())

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/textract-1.4.0-py2.7.egg/textract/parsers/utils.py", line 92, in run

command, pipe.returncode, stdout, stderr,

textract.exceptions.ShellError: The command `pdf2txt.py "/Applications/AMPPS/www/insidify_cv_training/files/2musa_bello.pdf"` failed because the executable

`pdf2txt.py` is not installed on your system. Please make

sure the appropriate dependencies are installed before using

textract:

http://textract.readthedocs.org/en/latest/installation.html

"

我正在mac上使用AMPPS伺服器。請問我該怎麼做?在