Labs ICT
Pro Login

Installation & Setup

How to install NumPy and get started.

Installation & Setup

Okay, let's get you set up with NumPy. The good news is it's super simple. If you have Python installed, you're almost there.

Installing with pip

Open your terminal or command prompt and type this magic command:


pip install numpy
    

That's it! pip will download and install NumPy and all its dependencies. If you're using Anaconda, it comes pre-installed with NumPy.

Importing NumPy

Once installed, you import it in your Python code. The convention is to import it as np - it saves typing and everyone in the community does it.


import numpy as np
print(np.__version__)
    

This will print the NumPy version. If you see a version number, you're good to go. If you get an error, something went wrong with the installation.

Verifying Everything Works

Let's do a quick test to make sure everything is working properly.


import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print("Success! NumPy is working.")
print(f"Array: {arr}")
print(f"Shape: {arr.shape}")
print(f"Data type: {arr.dtype}")
    

One thing I definitely did when I started was skip this verification step. Then I spent hours debugging only to find out NumPy wasn't installed properly. Always verify!

Try it Yourself →

Key Takeaways

  • Install NumPy with: pip install numpy
  • Import it as np for convenience: import numpy as np
  • Verify installation by creating a simple array
  • Check the version with np.__version__