SoFunction
Updated on 2024-11-21

Python Beginner's Tutorial (Thirty-nine) Python's NumPy Installation and Getting Started

Installing NumPy

Installing NumPy is easy if you already have Python and PIP installed on your system.

Please use this command to install it:

C:\Users\Your Name>pip install numpy

If this command fails, use a python distribution that already has NumPy installed, e.g. Anaconda, Spyder, etc.

Importing NumPy

After installing NumPy, import it into your application by adding the import keyword:

import numpy

Now Numpy is imported and ready to use.

an actual example

import numpy 
arr = ([1, 2, 3, 4, 5]) 
print(arr)

running example

NumPy as np

NumPy is usually imported with the np alias.

Alias: In Python, an alias is an alternative name for referring to the same thing.

Please use the as keyword to create an alias when importing:

import numpy as np

It is now possible to refer to the NumPy package as np instead of numpy.

an actual example

import numpy 
arr = ([1, 2, 3, 4, 5]) 
print(arr)

running example

Checking the NumPy Version

The version string is stored in theversion attributes

an actual example

import numpy as np
print(np.__version__)

running example

To this point this tutorial on Python Getting Started (Thirty-nine) Python's NumPy installation and Getting Started article is introduced to this, more related to Python's NumPy installation and Getting Started content, please search for my previous posts or continue to browse the following related articles I hope that you will support me in the future more!