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

error on calling setup(<'code-of-language'>) #3

Closed
jintgeorge opened this issue Mar 29, 2019 · 20 comments
Closed

error on calling setup(<'code-of-language'>) #3

jintgeorge opened this issue Mar 29, 2019 · 20 comments

Comments

@jintgeorge
Copy link


RuntimeError Traceback (most recent call last)
in
----> 1 setup('ml')

~/anaconda3/lib/python3.7/site-packages/inltk/inltk.py in setup(language_code)
21 loop = asyncio.get_event_loop()
22 tasks = [asyncio.ensure_future(download(language_code))]
---> 23 learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
24 loop.close()
25

~/anaconda3/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future)
569 future.add_done_callback(_run_until_complete_cb)
570 try:
--> 571 self.run_forever()
572 except:
573 if new_task and future.done() and not future.cancelled():

~/anaconda3/lib/python3.7/asyncio/base_events.py in run_forever(self)
524 self._check_closed()
525 if self.is_running():
--> 526 raise RuntimeError('This event loop is already running')
527 if events._get_running_loop() is not None:
528 raise RuntimeError(

RuntimeError: This event loop is already running

Done!

@jintgeorge jintgeorge changed the title error on calling setup(<'language'>) error on calling setup(<'code-of-language'>) Mar 29, 2019
@goru001
Copy link
Owner

goru001 commented Mar 29, 2019

Thanks for reaching out!
Can you please add info on how to reproduce this issue? I'm not able to reproduce.

@jintgeorge
Copy link
Author

Oh Wait !. I am running on a Mac. Might be the issue ?

@goru001
Copy link
Owner

goru001 commented Mar 29, 2019

This should not be an issue with running on a Mac. Are you able to reproduce it?
If not, I would suggest closing the current python session and running it again! It should work!

@gayatrivenugopal
Copy link

I am also getting an error on this line but the error is:
Traceback (most recent call last):
File "test.py", line 3, in
setup('hi')
File "/usr/local/lib/python3.7/site-packages/inltk/inltk.py", line 23, in setup
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/inltk/inltk.py", line 15, in download
learn = await setup_language(language_code)
File "/usr/local/lib/python3.7/site-packages/inltk/download_assets.py", line 29, in setup_language
await download_file(config['lm_model_url'], path/'models'/f'{language_code}', config["lm_model_file_name"])
File "/usr/local/lib/python3.7/site-packages/inltk/download_assets.py", line 20, in download_file
data = await response.read()
File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 969, in read
self._body = await self.content.read()
File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 359, in read
block = await self.readany()
File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 381, in readany
await self._wait('readany')
File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 297, in _wait
await waiter
File "/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 585, in exit
raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError

@goru001
Copy link
Owner

goru001 commented Mar 29, 2019

@gayatrivenugopal It looks like your internet connection went down while downloading models. It should work out fine if you'll retry! When you call setup('hi'), we try to download model which is ~100-150 Mb in size, so need internet to work during that period!

@goru001
Copy link
Owner

goru001 commented Mar 30, 2019

@jintgeorge, @gayatrivenugopal I'll close this issue, as this doesn't seem to be a problem with iNLTK - feel free to reopen and get back with the instructions to reproduce!
Thank you!

@goru001 goru001 closed this as completed Mar 30, 2019
@smehta688
Copy link

@goru001 encountered same error on calling setup(<'code-of-language'>) in Mac for hindi .
kindly help..??

@goru001
Copy link
Owner

goru001 commented May 6, 2020

@smehta688 Can you post the Traceback of the error you're getting?

@Aditdoshi1
Copy link

@smehta688 @jintgeorge @goru001
The error is caused because of pytorch, you have to downgrade pytorch to eliminate the error.
Try this:

conda uninstall pytorch
conda install pytorch==1.3.1 -c pytorch

and then run the same file without setup('hi') line, run the code in Jupyter notebook.
It will show some warnings, but the output will be displayed

@narayanacharya6
Copy link

narayanacharya6 commented Oct 5, 2020

Tried to uninstall and install of PyTorch but still run into this issue. Trace below.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-8e7b3034c8db> in <module>()
      1 from inltk.inltk import setup
----> 2 setup('sa')

2 frames
/usr/local/lib/python3.6/dist-packages/inltk/inltk.py in setup(language_code)
     26     loop = asyncio.get_event_loop()
     27     tasks = [asyncio.ensure_future(download(language_code))]
---> 28     learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
     29     loop.close()
     30 

/usr/lib/python3.6/asyncio/base_events.py in run_until_complete(self, future)
    469         future.add_done_callback(_run_until_complete_cb)
    470         try:
--> 471             self.run_forever()
    472         except:
    473             if new_task and future.done() and not future.cancelled():

/usr/lib/python3.6/asyncio/base_events.py in run_forever(self)
    423         self._check_closed()
    424         if self.is_running():
--> 425             raise RuntimeError('This event loop is already running')
    426         if events._get_running_loop() is not None:
    427             raise RuntimeError(

RuntimeError: This event loop is already running

@NikhilSKashyap
Copy link

@narayanacharya6 even I got a similar error. I git cloned the repository and ran the code in my terminal. It worked perfectly. But I received the same error in the jupyter notebook. The problem is with the iPython kernel and asyncio package. This StackOverflow answer gave me some clarity regarding the error - https://stackoverflow.com/questions/60926440/why-do-i-get-runtimeerror-this-event-loop-is-already-running.

@goru001 Please look into the same.

@sssanthosh107
Copy link

sssanthosh107 commented Nov 23, 2020

I also faced the same issue with Jupiter notebook and Google colab.
I left the notebook as such after getting the runtime error. after some time I got the message as "done!".
Post that I tried using the other commands and it was working fine.

@Nishant01-ai
Copy link

Hi, even after getting the message "Done!". The next line to "identify_language" is not working and throwing the same message:
"RuntimeError: This event loop is already running.
@goru001 Kindly suggest.

@adi-t-ya
Copy link

adi-t-ya commented Feb 3, 2022

@Nishant01-ai : were you able to figure out how to fix the issue?

@goru001
Copy link
Owner

goru001 commented Feb 3, 2022

Apologies @Nishant01-ai , @adi-t-ya , @NikhilSKashyap , @narayanacharya6 for missing out on your comments in this thread.

You do get

"RuntimeError: This event loop is already running."

error on colab but if you'll wait for 4-5 minutes till the model gets downloaded, and then use inltk functionality normally as you would otherwise, you should be able to do that. I just did this in a colab notebook and it seems to be working fine. Please checkout this notebook and let me know if it still doesn't work. Just wait for 4-5 mins for model to download after you get the error "RuntimeError: This event loop is already running."

@Gautamshahi
Copy link

Still, there is the same error. Even in the shared notebook, I can see the error.

@adi-t-ya
Copy link

adi-t-ya commented Feb 4, 2022

Hi @goru001, I was not able to run your colab notebook but was able to run it locally on my computer. I am trying to identify hinglish text using identify_language but it seems to classify the text as english. All other languages seem to work fine. Would you know how to fix it?

@goru001
Copy link
Owner

goru001 commented Feb 4, 2022

Hi @Gautamshahi , @adi-t-ya - In case my previous comment was not clear, On google colab, you will see the runtime error (as you see in cell 3 of the notebook), but if you'll wait for 4-5 mins for model to download and then use inltk's functionality (as shown in cell 4 of the notebook, where I get embedding vector for a hindi word), you should be able to use inltk as usual. In other words, the runtime error in this case doesn't stop you from using inltk as usual.

Having said that, if you have the bandwidth to see how we can resolve this runtime error on google colab to improve user experience and contribute, it'll be great.

@goru001
Copy link
Owner

goru001 commented Feb 4, 2022

@adi-t-ya To your comment on language identification for code-mixed languages, there is this open issue for this, and there's this PR where it is being worked upon, but no support in master branch as of today.

@TheGhoul27
Copy link

Hi, I am also getting the same error. I am installing locally on my laptop.
Please help with the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests