I use a jupyter notebook and run twint.
Code
c = twint.Config() c.Username = 'twitter' c.Limit = 20 twint.run.Followers(c) The above commands produce a runtime error relating to (I believe) the code attempting to create 2 asynchronous event loops. Traceback as follows:
RuntimeError Traceback (most recent call last) <ipython-input-4-4713cc05fb59> in <module>() ----> 1 twint.run.Favorites(c) ~/coding/tools/twint/twint/run.py in Favorites(config) 119 def Favorites(config): 120 config.Favorites = True --> 121 run(config) 122 123 def Followers(config): ~/coding/tools/twint/twint/run.py in run(config) 115 116 def run(config): --> 117 get_event_loop().run_until_complete(Twint(config).main()) 118 119 def Favorites(config): ~/.pyenv/versions/3.6.5/lib/python3.6/asyncio/base_events.py in run_until_complete(self, future) 453 future.add_done_callback(_run_until_complete_cb) 454 try: --> 455 self.run_forever() 456 except: 457 if new_task and future.done() and not future.cancelled(): ~/.pyenv/versions/3.6.5/lib/python3.6/asyncio/base_events.py in run_forever(self) 407 self._check_closed() 408 if self.is_running(): --> 409 raise RuntimeError('This event loop is already running') 410 if events._get_running_loop() is not None: 411 raise RuntimeError( RuntimeError: This event loop is already running 1 Answer
I have found a solution for Jupyter notebooks using the nest_async
Simply do
pip install nest_asyncio And add these lines.
import nest_asyncio nest_asyncio.apply() 1