JFerro
JFerro

Reputation: 3433

pip install a spacy language model in a particular folder

I would like to pip install several language models in a particular folder different than the default one.

How to proceed?

The following does not seem to work:

pip install /shared/public/spacy/en_core_web_lg-3.0.0-py3-none-any.whl

see: https://github.com/explosion/spacy-models/releases//tag/en_core_web_lg-3.0.0

With the typical installation procedure: python -m spacy download en_core_web_lg I can not control the folder.

the use case here is install the model in a folder available to everyone in a server in order to avoid multiple downloads.

NOTE: I already have Spacy installed in my particular virtual environment, i.e. I dont need to create a new one. Actually in my particular environment I do have the small language model of spacy for English. The question relates ONLY to installing yet another language model, the large one, in a particular folder, and being able to load that model from that folder.

thanks

Upvotes: 2

Views: 1337

Answers (2)

Melcfrn
Melcfrn

Reputation: 7

as mentionned is this another similar question : https://stackoverflow.com/a/67337134

You can install the model and then save it in the directory of your choice. In a terminal

python -m spacy download en_core_web_lg

And then in python

import spacy
nlp = spacy.load("en_core_web_lg")
nlp.to_disk(your_directory)

Upvotes: 1

Ethan Rodrigo
Ethan Rodrigo

Reputation: 355

you should use a python virtual environment (A python environment such that python interpreter). With virtual environment you can install any package apart from the default python path, which means all packages you will install will be isolated.

to make a python virtual environment in windows. open cmd and enter following

python -m venv path\that\you\want  (this will make a virtual environment)
path\that\you\entered\Scripts\activate.bat (to activate your virtual environment type path and \Scripts\activate.bat)

If you are in linux. Try following...

python3 -m venv path\to\your\venv (path that you want to make venv)
source path\to\your\venv\bin\activate (type path and \bin\activate)

then you can install python packages as usual with cmd\terminal

pip install spacy

Upvotes: 0

Related Questions