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

Loguru issues with pyinstaller #118

Closed
Rafficer opened this issue Jul 23, 2019 · 2 comments
Closed

Loguru issues with pyinstaller #118

Rafficer opened this issue Jul 23, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@Rafficer
Copy link

I can't get Loguru to work with pyinstaller. Maybe someone can help me out.

Running the python file directly works perfectly fine and packaging with pyinstaller also works, but running the pyinstaller package then throws an Error.

Python Version: 3.7.3
Loguru Version: 0.3.1
Pyinstaller Version: 3.5
OS: Fedora 30

Steps to reproduce:

  1. Write a simple script test.py with the following contents:
from loguru import logger
print("test")
logger.debug("Testlog")
  1. Pack it with pyinstaller:

pyinstaller test.py

  1. Run the pyinstaller package

./dist/test/test

I'm then met with the following error:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/__init__.py", line 10, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/_logger.py", line 18, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/_better_exceptions.py", line 2, in <module>
ModuleNotFoundError: No module named 'distutils'
[105097] Failed to execute script test

When I use pyinstaller with the --hidden-import=distutils flag, it doesn't work either but just gives me this error instead:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/__init__.py", line 10, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/_logger.py", line 18, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "loguru/_better_exceptions.py", line 2, in <module>
  File "/home/user/Documents/pyinstaller-test/.venv/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "distutils/__init__.py", line 44, in <module>
ImportError: cannot import name 'dist' from 'distutils' (/home/user/Documents/pyinstaller-test/dist/test/distutils/__init__.pyc)
[104459] Failed to execute script test

I didn't yet come further than this...

Would greatly appreciate any help!

Thank you!

@Rafficer
Copy link
Author

Turns out it was no issue with loguru. It was an issue with pyinstaller and/or virtualenv.

This fixed it: pyinstaller/pyinstaller#4064 (comment)

@Delgan
Copy link
Owner

Delgan commented Jul 23, 2019

Thanks for the information, @Rafficer!

As distutils is not fundamentally required for loguru to work correctly, I will probably add a try / except block around the import distutils, just in case. 🙂

@Delgan Delgan added the bug Something isn't working label Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants