- How to Check the NumPy Version
- Check the NumPy version using __version__ attribute
- Get the Detailed Version of NumPy
- Get the NumPy version using pip3
- Verify the NumPy version on Anaconda Distribution.
- Print the NumPy version in Command Line
- Conclusion
- Python 3: Как узнать версию библиотеки Pandas, Numpy
- Вариант 1. Узнаем версию библиотеки в скрипте Python
- Вариант 2. Проверить с помощью pip менеджера пакетов
- pip list
- pip freeze
- pip show
- Anaconda — conda list
- How to Check Numpy Version in Python ? 5 Methods
- Various Method to Check Numpy Version in Python
- Method 1: Checking numpy version using two dot operators
- Method 2 : Two underlines in the beginning and in the end
- Method 3: How to check the version of numpy in cmd
- Method 4: Check numpy version using pip
- Method 5: Know numpy version with other modules.
- END NOTES
- Join our list
How to Check the NumPy Version
There are multiple ways to check the NumPy version; however, the easiest and PEP8 standard practice is to import numpy and use the numpy.__version__ attribute to get the exact version details.
This guide will look at various ways to get the NumPy version. Let us look at each of the approaches using code examples.
Check the NumPy version using __version__ attribute
The easiest and Pythonic way to get the NumPy version is by using the __version__ attribute. This is the standard way to check the version of any standard Python libraries.
import numpy print(numpy.__version__)
Get the Detailed Version of NumPy
If you need detailed information on the NumPy version, then we can use np.version . The version.py file gets generated using setup.py when we install the NumPy package, and it holds the version information such as version, short_version, full_version, etc.
import numpy as np print(np.version.version) print(np.version.short_version) print(np.version.full_version) print(np.version.git_revision) print(np.version.release)
1.21.6 1.21.6 1.21.6 ef0ec786fd4c7622ad2fa0e54d3881f3b9bbd792 True
Note: The version, short_version, full_version will have the same value. If it's not a release version then the git_revision is added to the version and full_version.
Get the NumPy version using pip3
We can use the pip3 command to get the NumPy version. There are multiple ways to get the NumPy version using the pip command.
The pip3 list command will list all the packages installed in your system or virtual environment.
numpy 1.21.6 openpyxl 3.0.10 pandas 1.1.5
Instead of listing all the packages, you can find the NumPy package by using the command
>> pip3 list | FINDSTR numpy numpy 1.21.6
$ pip list | grep numpy numpy 1.21.6
The second approach is to use the pip3 show command. It will provide complete information(version, author, installation path, license, etc.) on NumPy if installed on your machine or virtual environment.
Name: numpy Version: 1.21.6 Summary: NumPy is the fundamental package for array computing with Python. Home-page: https://www.numpy.org Author: Travis E. Oliphant et al. Author-email: License: BSD Location: c:\users\m1014107\appdata\local\programs\python\python37\lib\site-packages Requires: Required-by: pandas
The third approach is to use pip3 freeze to get any Python package version without opening the Python shell.
>> pip freeze | FINDSTR 'numpy' numpy==1.21.6
$ pip freeze | grep 'numpy' numpy==1.21.6
Verify the NumPy version on Anaconda Distribution.
We can get the NumPy version in the Anaconda distribution using the conda command. Open the Anaconda prompt and type the below command.
# Name Version Build Channel numpy 1.21.6 py38h34a8a5c_0 numpy-base 1.21.6 py38haf7ebc8_0 numpydoc 1.1.6 pyhd3eb1b0_1
numpy 1.21.6 py38h7241aed_0 numpy-base 1.21.6 py38h6575580_1 numpydoc 1.1.6 py_0
Print the NumPy version in Command Line
The other alternate way is to use the command line and print the NumPy version, as shown below.
python3 -c "import numpy; print(numpy.__version__)" python -c "import numpy; print(numpy.__version__)"
Conclusion
There are multiple ways to check the NumPy version; the Pythonic and PEP8 standard ways are to use the numpy.__version__ attribute. Alternatively, we can also use the pip3 command to get the Python version.
Python 3: Как узнать версию библиотеки Pandas, Numpy
Вариант 1. Узнаем версию библиотеки в скрипте Python
Для того, чтобы узнать версию библиотеки, необходимо вбить следующую команду (например для Pandas):
import pandas as pd print (pd.__version__)
Пример для Numpy:
import numpy as np print (np.__version__)
Вариант 2. Проверить с помощью pip менеджера пакетов
С помощью менеджера пакетов pip можно проверить версию установленных библиотек, для этого используются команды:
pip list
Выведет список установленных пакетов, включая редактируемые.
pip freeze
Выводит установленные пакеты, которые ВЫ установили с помощью команды pip (или pipenv при ее использовании) в формате требований.
Вы можете запустить: pip freeze > requirements.txt на одной машине, а затем на другой машине (в чистой среде) произвести инсталляцию пакетов: pip install -r requirements.txt .
Таким образом вы получите идентичную среду с точно такими же установленными зависимостями, как и в исходной среде, в которой вы сгенерировал файл requirements.txt.
pip show
Выводит информацию об одном или нескольких установленных пакетах.
Anaconda — conda list
Если вы используете Anaconda, то вы можете проверить список установленных пакетов в активной среде с помощью команды conda list .
How to Check Numpy Version in Python ? 5 Methods
Do you want to check numpy version after the installion on numpy on your system. Then this article is for you. In this entire post you will know various ways to check numpy version in Python.
Various Method to Check Numpy Version in Python
Method 1: Checking numpy version using two dot operators
Here you have to use two dot operator and word “version” just like below. It output the version of currently installed numpy.
Method 2 : Two underlines in the beginning and in the end
You can use __version__ to know the current version of the installed numpy array.
Method 3: How to check the version of numpy in cmd
Just like you are writing code in your IDEs and outputting the numpy version. You can do so in command prompt also. Make sure that you have already installed numpy module.
Open your command prompt and type the following text and click on enter.
You will get the version number
Method 4: Check numpy version using pip
You can use the pip show command to know the version of the numpy array. Copy and paste the command below to output the version number.
Using this command you will get all the details about the python package like, Name,version, author ,summary ,location e.t.c which is very useful.
Method 5: Know numpy version with other modules.
There is also a way to know all the installed python pakages in your system. You will get module name and its version. Use the below command to get the all the modules name. Then look for the numpy and its version
END NOTES
These are various method I have compiled for you. You can use any method as per your convenience to check numpy version in python. If you ask me which one you should use then it depends upon where are you coding. For example If I am using pycharm then I will use the first and second one and if in command prompt then method 3 and 4. And method 5 if you are using python shell.
Hope this article has completed your confusion on how to numpy version in python. If you have any other queries then you can contact us.
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
We respect your privacy and take protecting it seriously
Thank you for signup. A Confirmation Email has been sent to your Email Address.