如何在Google Colab上安装模型/下载程序包? [英] How to install models/download packages on Google Colab?

查看:724
本文介绍了如何在Google Colab上安装模型/下载程序包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用文本分析库"Spacy".我已经在Google Colab笔记本上安装了spacy,没有任何问题.但是要使用它,我需要下载"en"模型.

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.

欢呼

推荐答案

如果您有Python解释器但没有终结器,则可以尝试:

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

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

更多手动替代方法可以在这里找到: https://spacy.io/usage/models# download-pip

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

从根本上讲,需要下载,解压缩模型文件并将其放入相应的site-packages目录中.您应该能够找到一种方便的方法来做到这一点,例如直接安装模型包.但是,如果您真的陷入困境,则可以通过查看已安装的任何模块的__file__变量来获取路径,例如print(spacy.__file__).那应该告诉您site-packages目录在文件系统上的什么位置.

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.

这篇关于如何在Google Colab上安装模型/下载程序包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆