JustAnotherArchivist / snscrape

A social networking service scraper in Python
GNU General Public License v3.0
4.5k stars 712 forks source link

`AttributeError` crash on `find_module` #782

Open blobb999 opened 1 year ago

blobb999 commented 1 year ago

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

JustAnotherArchivist commented 1 year ago

Interesting. PyInstaller recently removed PEP 302 support in https://github.com/pyinstaller/pyinstaller/commit/d59c96ad84b5474e9880537e2ee04a97d394ffdd, 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.

Rapid1898-code commented 1 year ago

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 commented 1 year ago

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

JustAnotherArchivist commented 11 months ago

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

Mosesofmason commented 9 months ago

same issue, any update?

SureshS03 commented 8 months ago

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 commented 5 months ago

For me this worked just fine: