Home > Software design >  Load a package from github and url ending in .git
Load a package from github and url ending in .git

Time:01-11

I try to import a Python package from github. I am working in Google Colab.

The repository is at the following url https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.

So I use the following code

!pip install --upgrade 
!pip install -q git git://github.com/microsoft/nlp-recipes/tree/master/utils_nlp
from utils_nlp import *

I tried as well

!pip install -q git https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp

I saw other (working) examples where the url ends in .git :

!pip install -q git https://github.com/huggingface/transformers.git

so I tried in turn

!pip install -q git https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.git

But I also noticed that https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.git loads to an error page while https://github.com/huggingface/transformers.git load to https://github.com/huggingface/transformers which surprises me.

How do we load the Python package here ?

CodePudding user response:

This is the correct way to install it:

pip install git https://github.com/microsoft/nlp-recipes.git

You can't install a module, only a package can be installed. After the installation you can go on with the rest of your code

from utils_nlp import *
...
  •  Tags:  
  • Related