0

Is there a way to include Ghostscript with cx_freeze in virtualenv

I have tried this pip install python3_ghostscript-0.5.0-py3-none-any.whl but still getting below error

Downloaded the .whl file from this link - https://pypi.python.org/packages/6a/2d/e2d7474bea24d223d5dc86d51241fd305b75a9168f2e1d7ee07b883c80a5/python3_ghostscript-0.5.0-py3-none-any.whl#md5=0e3a24a374c0d9cc1f2008801ead6927

Error: RuntimeError: Please make sure that Ghostscript is installed

Installing the Ghostscript in my Windows system won't solve the problem as I need to include it in my build from cx_freeze so that non-python installed systems can use my desktop application which is build using Tkinter

Basically I am using camelot to convert pdf tables to excel but it needs Ghostscript

Any alternative solutions are more than welcome!

Thanks in Advance!

Rocky
  • 950
  • 1
  • 7
  • 12
  • Why not simply add the Ghostscript installer to the installer for your desktop application ? This isn't really a Ghostscript question.... – KenS Jul 30 '20 at 07:25
  • Thanks KenS for your suggestion, but I don't want user to install anything, the application is build to just click a button and convert pdf tables to excel (Multiple files). Installing anything in my organization is not permitted, it needs admin access – Rocky Jul 30 '20 at 07:38

2 Answers2

3

I believe I have found an answer

I just need to use flavor='stream' in my code as stream doesn't use Ghostscript

tables = camelot.read_pdf(filename, pages=input_page_nos, flavor='stream')
Rocky
  • 950
  • 1
  • 7
  • 12
0

If you're in luck, you may be able to simply zip up your Ghostscript installation, bundle the zip with your software (I'm sure there's a way to bundle up arbitrary files with cx_freeze).

You can then have your program unzip Ghostscript to a temporary folder (or a known folder). After that, you'll probably need to hack camelot.ext.ghostscript._gsprint.__win32_finddll() to only look for the DLL in that installation folder, since there won't be any of those registry keys that would usually exist.

Good luck!

AKX
  • 152,115
  • 15
  • 115
  • 172