Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docx2pdf not found when building using pyinstaller #5

Open
prickett opened this issue Mar 3, 2020 · 12 comments
Open

docx2pdf not found when building using pyinstaller #5

prickett opened this issue Mar 3, 2020 · 12 comments
Labels
question Further information is requested

Comments

@prickett
Copy link

prickett commented Mar 3, 2020

I'm trying to build my project using pyinstaller and am running into a "library not found" error for docx2pdf. I'm not sure what is causing this problem. Have you used pyinstaller with docx2pdf? And if so, have you had the same problem?

  File "c:\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\docx2pdf\__init__.py", line 13, in <module>
  File "importlib\metadata.py", line 472, in version
  File "importlib\metadata.py", line 445, in distribution
  File "importlib\metadata.py", line 169, in from_name
importlib.metadata.PackageNotFoundError: docx2pdf
@AlJohri
Copy link
Owner

AlJohri commented Apr 15, 2020

@prickett sorry I don't have much experience with pyinstaller. If you include an easily reproducible example I can try and take a look

@AlJohri AlJohri added the question Further information is requested label Apr 15, 2020
@acrete
Copy link

acrete commented Aug 11, 2020

pyinstaller is missing hook script to run docx2pdf.

save hook-docx2pdf.py to \Lib\site-packages\PyInstaller\hooks

from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all('docx2pdf')

Run pyinstaller — onefile youscript.py

@efka84
Copy link

efka84 commented Aug 26, 2020

@acrete s solution works. here detailed>
go to Lib\site-packages\PyInstaller\hooks folder. open the fiile hook-docx2pdf.py remove or comment its content and paste
from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all('docx2pdf')

@AnAlpaca
Copy link

AnAlpaca commented Sep 3, 2020

this solution seemed to work for me if I dont select onefile option. However when i do select onefile my exe just shows a blank console with nothing running?

@aklauritzen
Copy link

@acrete Your solution worked perfectly! Thanks.

@AlJohri
Copy link
Owner

AlJohri commented Oct 4, 2020

glad ya'll got it working! I'm not super familiar with PyInstaller, but is there something I can do on the library side to make it easier?

@aklauritzen
Copy link

@AlJohri I'm not super familiar with PyInstaller either, so I don't have any suggestions at the moment. Docx2pdf works like a charm and suited perfectly for our project. Thank you for sharing your work!

@katie-q-ch
Copy link

There is an error in the docx2pdf code. It is about the version. It does not seem that there is a version. A friend helped me to solve this by setting version =1 where it says #version = version(package). The version was set as followed: version = 1 and this solved the problem I had.

@AlJohri
Copy link
Owner

AlJohri commented Apr 8, 2021

hi @KieuHa! I don't believe this is an error. There certainly is a version that is being set dynamically using importlib.metadata.version. The version is set here:

version = "0.1.7"

However, it looks like pyinstaller require hardcoding this value based on these issues?

Would you mind sending the specific error / stacktrace you receive when the version is dynamically set?

@mmelb
Copy link

mmelb commented May 17, 2021

https://stackoverflow.com/questions/66676982/pyinstaller-doesnt-recognize-docx2pdf-library The answer here worked for me, pyinstaller works fine after commenting out those lines.

@ghost
Copy link

ghost commented Aug 27, 2021

hi @KieuHa! I don't believe this is an error. There certainly is a version that is being set dynamically using importlib.metadata.version. The version is set here:

version = "0.1.7"

However, it looks like pyinstaller require hardcoding this value based on these issues?

Would you mind sending the specific error / stacktrace you receive when the version is dynamically set?

try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata
version = metadata.version("jsonschema")

@ghost
Copy link

ghost commented Aug 27, 2021

https://stackoverflow.com/questions/66676982/pyinstaller-doesnt-recognize-docx2pdf-library The answer here worked for me, pyinstaller works fine after commenting out those lines.
can you try :
try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata
version = metadata.version("jsonschema")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants