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

AttributeError crash on find_module #782

Open
blobb999 opened this issue Mar 20, 2023 · 7 comments · May be fixed by #1036
Open

AttributeError crash on find_module #782

blobb999 opened this issue Mar 20, 2023 · 7 comments · May be fixed by #1036
Labels
bug Something isn't working modules

Comments

@blobb999
Copy link

blobb999 commented Mar 20, 2023

Describe the bug

Traceback (most recent call last):
  File "SaS_on_Twitter.py", line 14, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "snscrape\modules\__init__.py", line 17, in <module>
  File "snscrape\modules\__init__.py", line 13, in _import_modules
AttributeError: 'FrozenImporter' object has no attribute 'find_module'
[3260] Failed to execute script 'SaS_on_Twitter' due to unhandled exception!

How to reproduce

Compiled with:
pyinstaller --onefile --hidden-import snscrape.modules SaS_on_Twitter.py

Expected behaviour

it should just run like in idle, but as stand-alone exe

Screenshots and recordings

No response

Operating system

Windows 10

Python version: output of python3 --version

3.8 or 3.11.24

snscrape version: output of snscrape --version

0.6.1.20230314

Scraper

Twitter-User

How are you using snscrape?

Module (import snscrape.modules.something in Python code)

Backtrace

No response

Log output

No response

Dump of locals

No response

Additional context

No response

@blobb999 blobb999 added the bug Something isn't working label Mar 20, 2023
@JustAnotherArchivist
Copy link
Owner

Interesting. PyInstaller recently removed PEP 302 support in pyinstaller/pyinstaller@d59c96a, first released in version 5.8.0. Presumably, if you used an older version, it should work.

There is still something to be improved in snscrape though. find_module was deprecated by PEP 451 and is officially deprecated in importlib.abc.Finder since Python 3.10. This should be replaced. Thanks, I was unaware of that.

@JustAnotherArchivist JustAnotherArchivist changed the title snscrape does not work if build project as standalone .exe snscrape modules importer uses deprecated find_module Mar 20, 2023
@Rapid1898-code
Copy link

So the only solution currently is to use a pyinstaller version < 5.8.0 when i want to create an executeble with snscrape.
Do i understand this correct?

@JustAnotherArchivist
Copy link
Owner

That is correct.
I briefly looked into replacing this recently, but it's more complicated than I currently have time for.

@JustAnotherArchivist
Copy link
Owner

As @xts-bit reported in #1038, this also affects Python 3.12 where find_module has been removed.

@JustAnotherArchivist JustAnotherArchivist changed the title snscrape modules importer uses deprecated find_module AttributeError crash on find_module Dec 16, 2023
@Mosesofmason

This comment was marked as spam.

@SureshS03
Copy link

SureshS03 commented Mar 4, 2024

Interesting. PyInstaller recently removed PEP 302 support in pyinstaller/pyinstaller@d59c96a, first released in version 5.8.0. Presumably, if you used an older version, it should work.

There is still something to be improved in snscrape though. find_module was deprecated by PEP 451 and is officially deprecated in importlib.abc.Finder since Python 3.10. This should be replaced. Thanks, I was unaware of that.

hey even i installed pyinstaller but its shows the same error

@cyterat
Copy link

cyterat commented Jun 8, 2024

For me this worked just fine:

  • python=3.10
  • pyinstaller==5.7.0
  • snscrape==0.7.0.20230622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants