JustAnotherArchivist / snscrape

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

AttributeError: 'FileFinder' object has no attribute 'find_module' #1041

Closed johndamiani closed 9 months ago

johndamiani commented 9 months ago

I am runnung python 3.12 and snscrape version ( 0.7.0.20230622).

I am getting the following error when I try to import the package. import snscrape.modules.twitter as sntwitter

Error: (ib_venv) johndamiani@Johns-MacBook-Air Portfolio_analyser_2 % /Users/johndamiani/Desktop/Portfolio_analyser_2/ib_venv/bin/python /Users/johndamiani/Desktop/Portfolio_analyser_2/testi ng.py Traceback (most recent call last): File "/Users/johndamiani/Desktop/Portfolio_analyser_2/testing.py", line 4, in import snscrape.modules.twitter as sntwitter File "/Users/johndamiani/Desktop/Portfolio_analyser_2/ib_venv/lib/python3.12/site-packages/snscrape/modules/init.py", line 17, in _import_modules() File "/Users/johndamiani/Desktop/Portfolio_analyser_2/ib_venv/lib/python3.12/site-packages/snscrape/modules/init.py", line 13, in _import_modules module = importer.find_module(moduleName).load_module(moduleName) ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'FileFinder' object has no attribute 'find_module'

Has anyone encountered this issue or has any ideas what might be causing this?

TheTechRobo commented 9 months ago

782 ?

AIConstructor commented 9 months ago

Maybe the code block which is revised acc. new version of python fixes :

Original code

`import importlib

all = []

def _import_modules(): prefixLen = len(name) + 1 for finder, name, ispkg in importlib.util.find_spec(path[0]).submodule_search_locations: if not ispkg: module_name = name[prefixLen:] all.append(module_name) module = importlib.import_module(name) globals()[module_name] = module

_import_modules() `

MrBytes10 commented 5 months ago

yes, i have tried to run this code and getting the same:

import snscrape.modules.twitter as sntwitter import pandas as pd

query= "python" for tweet in sntwitter.TwitterSearchScraper(query).get_items(): print(vars(tweet)) break

Ashique-1010 commented 2 months ago

snscrape does not seem to be supported in python version > 3.11 The module will work in python 3.10, 3.9. I've tried it in google colab and it works.