Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introduction to NumPy Meet NumPy Creating the Study Log

hiii.I need help.

In my jpuyter notebook it is showing 'np' is not defined and numpy has no attribute 'unit16'. How to solve it.Please let me know

Chris Freeman
Chris Freeman
Treehouse Moderator 68,428 Points

Please check:

  • Have you done: import numpy as np in a jupyter notebook cell?
  • Is numpy installed in the same environment as jupyter notebook was started?

2 Answers

I got this same error after coming back to my Jupyter notebook a day after going through the first section. I was able to resolve it my going into the field where I'd imported numpy as np and pressing shift+enter again to run that section again, then going back to the array and using shift+enter to run that again.

Linda Shum
Linda Shum
12,609 Points

Chris Freeman could you kindly help me find out how to check whether NumPy is installed in the same environment that the jupyter notebook was started in? Thanks.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,428 Points

Sorry. Missed this tag. In the window where you start up jupyter notebook, try the following:

# test if numpy accessible in current environment
$ python
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> exit()

# Install numpy
$ pip install numpy
Collecting numpy
  Downloading numpy-1.19.5-cp38-cp38-manylinux2010_x86_64.whl (14.9 MB)
    |████████████████████████████████| 14.9 MB 17.1 MB/s 
Installing collected packages: numpy
Successfully installed numpy-1.19.5

# retest if numpy accessible
$ python
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy

Need to restart jupyter notebook Success!!