Как узнать версию numpy
Перейти к содержимому

Как узнать версию numpy

  • автор:

How to check NumPy Version in Python?

In this article, we will discuss how to check the version of numpy in python.

Table Of Contents

What is numpy?

numpy stands for numeric python, and used to work on the arrays. It is a python module that can be imported directly.

There are multiple ways to check the version of numpy. Lets discuss all the methods one by one with proper approach and a working code example.

Using the version object

The version is the object available in python which is used to check the version of any kind of module. So by using this, we can check the version of the numpy module. But, before checking the version, we have to import the numpy module. We can import by using the import keyword.

Syntax:

Example:

Read More:

Let’s check the version of numpy module in our working environment.

Output:

Our numpy module version is 1.21.6

We can also check the version with version method using the following syntax:

Example:

Output:

Check numpy version using pip

The pip is a command used to install a module in python.

Syntax to install:

Where, module_name is the module to be installed. For example, we can also install the numpy module using,

Using pip, we can get information about any kind of module. In pip, there are different ways to get the version of numpy. Let’s discuss them one by one.

Check numpy version using show with pip

Syntax:

Where, module_name is the name of the module, Here it is numpy. The show used with pip will return the following

  1. Name: Refers to the module name
  2. Version: module version
  3. Summary: Module definition
  4. Home-page: Official website of the module
  5. Author: Author name of the module
  6. Author-email: Author email address
  7. License: module license
  8. Location: Location in which module has resided
  9. Requires: return list of other modules that need/uses the current module.

Example:

In this example, we will use show with pip to get the numpy details.

Output:

Check numpy version using list with pip

Syntax:

The list will return all module names followed by the module version.

Example:

Output:

From the above list, we can check that the numpy version is 1.21.6.

Check numpy version using FINDSTR with pip list

If we want to get only numpy module version from the list in Command Prompt. Then the FINDSTR is used to find the string i.e numpy module from the list.

Syntax:

Output:

The version of the numpy module is 1.21.4.

Check numpy version using numexpr module

The numexpr module is used to evaluate numerical expressions performed on the numpy arrays. The print_versions() in this module is used to display the numpy version.

Syntax:

Example:

Output:

Check numpy version using the pkg_resources module

This package helps to find, utilize and provide tools for python packages. The get_distribution() method will return the module version along with version() method.

Syntax:

where module_name is the name of the module. here it is numpy.

It will return only the version.

Example:

Output:

The numpy version is 1.21.6

Check numpy version using importlib_metadata module

The importlib_metadata provides the version method, to return the module version in python.

Syntax:

where module_name is the name of the module. Here it is numpy. It will return only the version.

Example:

Output:

The numpy version is 1.21.6

Summary

Great! you made it, we discussed 10 approaches to get the numpy version running in our python environment. Based on the python compiler and pip version, you can check the version of any module, Happy learning.

Related posts:

Advertisements

Thanks for reading.

Leave a Comment Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisements

Advertisements

Advertisements

Advertisements

Terms of Use

Disclaimer

Copyright © 2023 thisPointer

To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.

Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.

How to Check Numpy Version on Mac, Linux, and Windows

To check a numpy version on mac, linux, and windows platforms, write the numpy.__version__ code and run the Python file. It will return the current version of numpy installed on your machine.

There are the following alternate methods that can help you to check the numpy version.

  1. Use the pip list or pip3 list command.
  2. From the command line type: python3 -c “import numpy; print(numpy.__version__)”
  3. From command line type: pip3 freeze | grep ‘numpy’ or pip freeze | grep ‘numpy
  4. From command line type: pip3 show numpy or pip show numpy

Numpy is a powerful mathematical library that can be used as an efficient multi-dimensional container of generic data. Arbitrary data types can be defined.

The Numpy library allows seamless and speedy integration with various databases.

If you have not installed Numpy, check out the how to install numpy article. After installing, we need to check the version of Numpy.

Checking the Numpy version using numpy._version_

Create a file called app.py and write the following two lines of code inside that file.

Output

The latest version at the time of writing this tutorial is 1.23.5. Yours might be the oldest or latest, depending on your machine’s installation time.

Getting the numpy version using the pip3 list command

You can use the pip3 list command to list the packages, and if Numpy is installed in your system, it will appear with its version. For example, if you are using Python3, you can use the following command.

You can use the following command if you are using Python 2 or Python.

Printing the Numpy version

Print the Numpy version in the command line. Type the following command.

If you are using Python 2.x, you can use the following command.

Using the grep command to get the numpy version

Type the following command.

If you are using Python 2.x, then use the following command.

Using pip3 show command

Type the following command.

Checking the Numpy version on Anaconda Distribution

To check a numpy version on the Anaconda navigator, use the command conda list | grep numpy command.

FAQ

How to check the version of NumPy that is installed on my system?

You can check the version of NumPy by creating a Python file, and add numpy.__version__ code, and running the Python file that returns the current version of the numpy library.

How to upgrade or install a specific version of NumPy?

To install a specific version of NumPy, use this command: pip install numpy==1.18

To upgrade a numpy library in Python, use this pip install –upgrade numpy command.

How can I ensure that I have the latest version of NumPy installed?

To ensure that you have the latest version of NumPy installed, use this command: pip install –upgrade numpy.

Conclusion

The easy and fastest way to check the current numpy version is by adding numpy.__version__ code and run the Python file.

How do I check which version of NumPy I'm using?

Adriaan's user avatar

Should generate a list of packages. Scroll through to numpy.

You can also check if your version is using MKL with:

You can try this:

We can use pip freeze to get any Python package version without opening the Python shell.

Peter Mortensen's user avatar

Ajay Gupta's user avatar

If you’re using NumPy from the Anaconda distribution, then you can just do:

This gives the Python version as well.

If you want something fancy, then use numexpr

It gives lot of information as you can see below:

kmario23's user avatar

Works on both windows and linux. Should work on mac too if you are using pip.

You can get numpy version using Terminal or a Python code.

In a Terminal (bash) using Ubuntu:

In python 3.6.7, this code shows the numpy version:

If you insert this code in the file shownumpy.py, you can compile it:

I’ve got this output:

Rogelio Prieto's user avatar

For Python 3.X print syntax:

Just a slight solution change for checking the version of numpy with Python,

My projects in PyCharm are currently running version

In a Python shell:

Peter Mortensen's user avatar

LMB's user avatar

For Windows

For Linux

Pure Python line that can be executed from the terminal (both 2.X and 3.X versions):

If you are already inside Python, then:

Ginés Hidalgo's user avatar

It is good to know the version of numpy you run, but strictly speaking if you just need to have specific version on your system you can write like this:

pip install numpy==1.14.3 and this will install the version you need and uninstall other versions of numpy .

Python 3: Как узнать версию библиотеки Pandas, Numpy

Вариант 1. Узнаем версию библиотеки в скрипте Python

Для того, чтобы узнать версию библиотеки, необходимо вбить следующую команду (например для Pandas):

Пример для Numpy:

Вариант 2. Проверить с помощью pip менеджера пакетов

С помощью менеджера пакетов pip можно проверить версию установленных библиотек, для этого используются команды:

  • pip list
  • pip freeze
  • pip show pandas

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 .

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *