Community Conundrum 27: Stacks of Questions is live! Read More

Issues in Jupyter Notebook

Level 3
Issues in Jupyter Notebook

I am developing a python code for the use cases. I have changed the Jupyter notebook environment from python 2 to python 3. However, I am getting errors for any python code even for simple commands like "python3 --version" and "%pylab inline".

I am getting errors like 

NameError: name 'python3' is not defined

and for "%pylab inline"

ModuleNotFoundError: No module named 'matplotlib'

Kindly help us to solve this

0 Kudos
1 Reply
Dataiker
Dataiker

Hi,

If you write in a notebook cell python3 --version, it tries to execute that as Python code, but that's not valid Python code, hence the python3 is not defined

If you want to get the output of a shell command, you need to use !python3 --version (note the additional ! which means shell command in Jupyter).

For your pylab inline issue, it is because you have not installed the matplotlib package in your code env. %pylab inline is a shortcut for loading a lot of common packages, matplotlib being one of them. Simply go to the settings of your code env, add matplotlib and Save & Update