JWock82 / Pynite

A 3D structural engineering finite element library for Python.
MIT License
454 stars 93 forks source link

Cannot create PDF report #155

Closed LycanDragon closed 1 year ago

LycanDragon commented 1 year ago

Describe the bug Unable to create PDF report - followed all instructions in documentation, but throws error when I try. The analysis runs fine, just the PDF won't work.

Error

FileNotFoundError Traceback (most recent call last) ~\anaconda3\lib\site-packages\pdfkit\configuration.py in init(self, wkhtmltopdf, meta_tag_prefix, environ) 34 ---> 35 with open(self.wkhtmltopdf) as f: 36 pass

FileNotFoundError: [Errno 2] No such file or directory: b''

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_27980\2915544453.py in 143 asda=[[True, True, True, True, False, False], [True, True, True, False, False, False]] 144 tesco = Wire.ByVertices(verticesList, close=False) --> 145 FEA_Analysis(geometry=tesco, visualisation=False, supports=asda)

~\AppData\Local\Temp\ipykernel_27980\2915544453.py in FEA_Analysis(geometry, supports, visualisation, A, E, G, nu, rhoA, Iy, Iz, J, dead, live) 127 128 # Create the report --> 129 Reporting.create_report(feaModel, output_filepath='C://Users//HP Pavilion//Documents//My Report.pdf') 130 131 ##################################################################################

~\anaconda3\lib\site-packages\PyNite\Reporting.py in create_report(model, output_filepath, nodes, members, plates, member_releases, node_reactions, node_displacements, member_end_forces, member_internal_forces, plate_corner_forces, plate_center_forces, plate_corner_membrane, plate_center_membrane) 48 # Convert the HTML to pdf format using PDFKit 49 # Note that wkhtmltopdf must be installed on the system, and included on the system's PATH environment variable for PDFKit to work ---> 50 pdfkit.from_string(HTML, output_filepath, css=path / './MainStyleSheet.css') 51 52 return

~\anaconda3\lib\site-packages\pdfkit\api.py in from_string(input, output_path, options, toc, cover, css, configuration, cover_first, verbose) 70 """ 71 ---> 72 r = PDFKit(input, 'string', options=options, toc=toc, cover=cover, css=css, 73 configuration=configuration, cover_first=cover_first, verbose=verbose) 74

~\anaconda3\lib\site-packages\pdfkit\pdfkit.py in init(self, url_orfile, type, options, toc, cover, css, configuration, cover_first, verbose) 43 44 self.source = Source(url_orfile, type) ---> 45 self.configuration = (Configuration() if configuration is None 46 else configuration) 47 try:

~\anaconda3\lib\site-packages\pdfkit\configuration.py in init(self, wkhtmltopdf, meta_tag_prefix, environ) 36 pass 37 except (IOError, FileNotFoundError) as e: ---> 38 raise IOError('No wkhtmltopdf executable found: "%s"\n' 39 'If this file exists please check that this process can ' 40 'read it or you can pass path to it manually in method call, '

OSError: No wkhtmltopdf executable found: "b''" If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

JWock82 commented 1 year ago

Hi LycanDragon. There may be a couple of things going on here. First, the latest release of Pynite does have an issue with reporting, but I corrected it in the repository last week and will push out the fix with the next release. If you're running Pynite from an updated clone of the repo you shouldn't be seeing an issue though. Secondly, I've gotten that same error (No wkhtmltopdf executable found: "b''") myself after adding wkhtmltopdf to my PATH. I found a system reboot fixed the error. I presume it's because updates to the PATH are not effective until a reboot occurs.

JWock82 commented 1 year ago

This issue should be fixed now with the latest release. Let me know if you're still having problems.