Open In App

Install Specific Version of Spacy using Python PIP

Last Updated : 20 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

SpaCy is basically an open-source Natural Language Processing (NLP) library used for advanced tasks in the NLP field, written in programming languages like Python and Cython. Sometimes, in your project, you don’t want to use the updated version of SpaCy. In this case, you want to install the specific previous versions of Spacy. This article will let you know about installing the specific version of Spacy.

What is Specific in Python?

SpaCy is an open-source natural language processing (NLP) library for Python. It is designed to perform various NLP tasks, including tokenization, part-of-speech tagging, named entity recognition, and more. SpaCy is known for its efficiency, speed, and accuracy, making it a popular choice for developers and researchers working on projects that involve processing and understanding natural language text.

Installing Specific Version of SpaCy?

Below, is the step-by-step guide of How To Install Specific Version Of Spacy in Python.

Step 1: Create a Virtual Environment

First, create the virtual environment using the below commands

python -m venv env 
.\env\Scripts\activate.ps1

Step 2:  Install Spacy Library

To install a specific version of SpaCy, utilize the Python package manager “pip” in the command line or terminal of your operating system. Below are the commands to install a particular version, using version 3.2.3 of SpaCy as an example:

pip install spacy==3.2.3 # Windows
pip3 install spacy==3.2.3 # MacOS

file

To achieve the installation of a specific version and uninstall the latest version, use the following commands. In this example, version 3.2.3 of SpaCy is selected:

file

Step 3: Verify Using Pip

After successfully installing the specific version of SpaCy using the process outlined in step 1, you can verify the installation by executing the following commands in the command line or terminal of your operating system:

pip show spacy #Windows
pip3 show spacy # MacOS


file

The installed version 3.2.3 and many other details can be seen in the image above after typing the above commands in the terminal/command line ensuring that you have installed the desired version of SpaCy.

Code Examples

In this example, below code imports the SpaCy library and loads the English language model “en_core_web_sm.” It then tokenizes the given text using SpaCy and prints each token in a processed document.

Python3




import spacy
 
# Loading the en_core_web_sm model, that is,English language model
nlp = spacy.load("en_core_web_sm")
text = "SpaCy is an open-source library for advanced Natural Language Processing in Python."
doc = nlp(text)
 
# Iterating over tokens in the processed document and printing them.
print("Tokenization using spaCy:")
for token in doc:
    print(token.text)


Output

Tokenization using spaCy:
GeeksforGeeks
is
a
Coding
Platform
.

Conclusion

In conclusion , The SpaCy library which is popularly used in advanced NLP projects requires deep understanding and mastery of the versions and installations of specific versions in some NLP projects. By following the above process mentioned in this article, you can easily install the exact desired version of SpaCy, that is required for your NLP project needs.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads