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

Error while packaging sentry with pyinstaller #4755

Closed
6 tasks done
harshithdwivedi opened this issue Mar 17, 2020 · 2 comments
Closed
6 tasks done

Error while packaging sentry with pyinstaller #4755

harshithdwivedi opened this issue Mar 17, 2020 · 2 comments

Comments

@harshithdwivedi
Copy link

harshithdwivedi commented Mar 17, 2020

Description of the issue

I'm trying to package sentry_sdk with pyinstaller but it doesn't seem to work as I can't see it packaged in my app and running it throws an error about missing files related to sentry.

Version of the sentry sdk: 0.14.2

Context information (for bug reports)

  • Output of pyinstaller --version: 3.6

  • Version of Python: 3.7

  • Platform: OS X

    • start with clean installation
    • use the latest development version
    • Run your frozen program from a command window (shell) — instead of double-clicking on it
    • Package your program in --onedir mode
    • Package without UPX, say: use the option --noupx or set upx=False in your .spec-file
    • Repackage you application in verbose/debug mode.

A minimal example program which shows the error

Install the sentry-sdk

pip install sentry-sdk==0.14.2

Create and package a test main.py file

import sentry_sdk
# the contents of the init method don't matter
sentry_sdk.init("https://786465347564378658438684@sentry.io/7865487")

def main():
    print("Hello World")

Stacktrace / full error message

Traceback (most recent call last):
  File "aftershoot.py", line 17, in <module>
  File "sentry_sdk/hub.py", line 80, in _init
  File "sentry_sdk/client.py", line 80, in __init__
  File "sentry_sdk/client.py", line 110, in _init_impl
  File "sentry_sdk/integrations/__init__.py", line 106, in setup_integrations
  File "sentry_sdk/integrations/__init__.py", line 42, in iter_default_integrations
  File "importlib/__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sentry_sdk.integrations.logging'
[33776] Failed to execute script aftershoot
@Legorooj
Copy link
Member

You'll need to write a hook for sentry_sdk. Please see https://pyinstaller.readthedocs.io/en/stable/hooks.html and submit a PR

@ohadlahav
Copy link

ohadlahav commented Jun 3, 2020

This did the trick for me:

create hook-sentry_sdk.py with:

hiddenimports = [ "sentry_sdk.integrations.stdlib", "sentry_sdk.integrations.excepthook", "sentry_sdk.integrations.dedupe", "sentry_sdk.integrations.atexit", "sentry_sdk.integrations.modules", "sentry_sdk.integrations.argv", "sentry_sdk.integrations.logging", "sentry_sdk.integrations.threading" ]

and add --additional-hooks-dir=. for example.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants