How to install models/download packages on Google Colab?

丶灬走出姿态 提交于 2020-01-13 05:13:59

问题


I am using text analytics library "Spacy". I've installed spacy on Google Colab notebook without any issue. But for using it I need to download "en" model.

Generally, that command should look like this:

python -m spacy download en

I tried few ways but I am not able to get it to install on the notebook. Looking for help.

Cheers


回答1:


If you have a Python interpreter but not a teriminal, you could try:

import spacy.cli
spacy.cli.download("en_core_web_sm")

More manual alternatives can be found here: https://spacy.io/usage/models#download-pip

Fundamentally what needs to happen is the model file needs to be downloaded, unzipped, and placed into the appropriate site-packages directory. You should be able to find a convenient way to do that, e.g. by pip installing the model package directly. But if you get really stuck, you can get the path by looking at the __file__ variable of any module you have installed, e.g. print(spacy.__file__) . That should tell you where on your file-system the site-packages directory is.




回答2:


or you can use:

import en_core_web_sm
nlp = en_core_web_sm.load()



回答3:


!python -m spacy download fr_core_news_sm

Worked for me for the French model



来源:https://stackoverflow.com/questions/49259404/how-to-install-models-download-packages-on-google-colab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!