31

I have installed spaCy with python for my NLP project.

I have installed that using pip. How can I verify installed spaCy version?

using

pip install -U spacy

What is command to verify installed spaCy version?

Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62
  • 1
    Does this answer your question? [Find which version of package is installed with pip](https://stackoverflow.com/questions/10214827/find-which-version-of-package-is-installed-with-pip) – hc_dev Aug 04 '21 at 17:46

8 Answers8

46

You can also do python -m spacy info. If you're updating an existing installation, you might want to run python -m spacy validate, to check that the models you already have are compatible with the version you just installed.

syllogism_
  • 4,127
  • 29
  • 22
10

If you ask yourself: How to find any Python pkg version? This one should be used/ as well, not only for Spacy ofc:

The easiest (if you installed it using pip):

pip show spacy #pip3 if you installed it using pip3

Or:

python -m spacy --version

Or... just run python (with the version that you installed Spacy on) and use the version method

If you want to know the version of any Python pkg (package) you are working with this would work for you every time!

run:

python
>> import spacy
>> print(spacy.__version__)

Easy to do it with Pycharm built-in IDE console (Jupyter notebook)

Or, Either:

python -m spacy --version

or

python3 -m spacy --version #depends where it is install (python or python3)
Kohn1001
  • 3,507
  • 1
  • 24
  • 26
9

Use command - python -m spacy info to check spacy version

pallavi
  • 107
  • 1
  • 3
  • 1
    For me a duplicate, one year after [syllogism's answer](https://stackoverflow.com/a/47351587/5730279) it's still the same command. Can you expand to make your answer unique? – hc_dev Aug 04 '21 at 17:25
3

If you installed with pip you can try to find it with pip list and get version info with pip show <name>

voiDnyx
  • 975
  • 1
  • 11
  • 24
2

If you are using python3, you can use your package manager (pip) pip3 list and find spacy's version.
For Python 2.7+ pip list does the job

GodSaveTheDucks
  • 756
  • 5
  • 19
1

enter image description here

Simply use !python -m spacy info to get details on Jupyter notebook, remove ! for normal python command check.

Check the above screenshot to see the result details.

Thanks

1

Ways to find the spacy version installed:

  1. pip show spacy
  2. python -m spacy info
  3. python -m spacy validate

Below find how the output will be:

pip show spacy

Name: spacy
Version: 3.4.2
Summary: Industrial-strength Natural Language Processing (NLP) in Python
Home-page: https://spacy.io
Author: Explosion
Author-email: contact@explosion.ai
License: MIT
Location: c:\users\shraddha.shetty\appdata\local\programs\python\python310\lib\site-packages
Requires: catalogue, cymem, jinja2, langcodes, murmurhash, numpy, packaging, pathy, preshed, pydantic, requests, setuptools, spacy-legacy, spacy-loggers, srsly, thinc, tqdm, typer, wasabi
Required-by: en-core-web-sm, pyresparser

python -m spacy info

============================== Info about spaCy ==============================

spaCy version    3.4.2
Location         C:\Users\shraddha.shetty\AppData\Local\Programs\Python\Python310\lib\site-packages\spacy
Platform         Windows-10-10.0.19044-SP0
Python version   3.10.5
Pipelines        en_core_web_sm (3.4.1)

C:\Users\shraddha.shetty>python -m spacy validate
    ✔ Loaded compatibility table
    
    ================= Installed pipeline packages (spaCy v3.4.3) =================
    ℹ spaCy installation:
    C:\Users\shraddha.shetty\AppData\Local\Programs\Python\Python310\lib\site-packages\spacy
    
    NAME             SPACY            VERSION
    en_core_web_sm   >=3.4.0,<3.5.0   3.4.1     ✔
dataninsight
  • 1,069
  • 6
  • 13
0

Another way to get versions of Spacy and the dependencies is to use: pip freeze requirements.txt. See this link for the official documentation for both Mac and Windows OSs.

The main benefit I find with this approach is that you get a list of all dependencies plus the versions. Libraries are often times very picky about the versions. Using this method you can just share the requirements.txt with your collaborators and then they are good to go too :)

Edit: Thanks to hc_dev for the valuable comment.

  • I like the different perspective in your answer (persistent versions list). To make it stand out, you could (a) link to the respective pip-docs, (b) explain what the other benefits of `pip freeze` are (list all dependencies + version in a file). – hc_dev Aug 04 '21 at 17:29