import numpy as np
np.array([1,2,3,4])
Why I'm having this error
NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_2304/609253908.py in ----> 1 np.array([1,2,3,4])
NameError: name 'np' is not defined
CodePudding user response:
Your error code says that np.array([1, 2, 3, 4])
is in line 1
so you are trying to use it before importing, you need to import numpy
first, as shown in your question.
CodePudding user response:
You can just go with numpy
import numpy
numpy.array([1,2,3,4])
Have you installed or updated numpy? Try this once in your terminal.
>>> pip install numpy