JustAnotherArchivist / snscrape

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

AttributeError: module 'functools' has no attribute 'cached_property' #86

Closed lukaspistelak closed 3 years ago

lukaspistelak commented 3 years ago
    import snscrape.modules
  File "/usr/local/lib/python3.6/dist-packages/snscrape/modules/__init__.py", line 3, in <module>
    import snscrape.base
  File "/usr/local/lib/python3.6/dist-packages/snscrape/base.py", line 55, in <module>
    class Scraper:
  File "/usr/local/lib/python3.6/dist-packages/snscrape/base.py", line 75, in Scraper
    @functools.cached_property
AttributeError: module 'functools' has no attribute 'cached_property'

THE OS : ubuntu 18.04

but the version from pip works 0.3.4 !

JustAnotherArchivist commented 3 years ago

Duplicate of #75. You need Python 3.8.

lukaspistelak commented 3 years ago

ok, but my project depends on cca 100 libs in python 3.6.9 , so you can imagine how many libs i cant use ..... can u change it please? for 3.6.9

JustAnotherArchivist commented 3 years ago

Sorry, snscrape depends on a feature that is only available since Python 3.8.

If you want, you can try to patch snscrape. This error is the only 3.8 dependency at the moment, so you can probably get away with using @property instead of @functools.cached_property as long as you don't access the entity multiple times. However, expect more things to break in the future as the code will depend more and more on new language features over time.

lukaspistelak commented 3 years ago

What you mean exactly access the entity multiple times ?, i Run the Twitter search Class in thread, But in every thread I initialize The your Twitter Search Method

JustAnotherArchivist commented 3 years ago

TwitterUserScraper has an entity attribute that provides information on the user. This information is cached, and the retrieval is implemented with that in mind, i.e. that the underlying method is not called more than once. If you use @property instead of @functools.cached_property, that guarantee is broken. If you only use the TwitterSearchScraper or do not access the entity (more than once per scraper instance), it is safe to replace it.