[Tutor] math (pkg) in Jupyter Notebook

loomer at gmx.com loomer at gmx.com
Sun Mar 8 00:20:12 EST 2020


Hi
I'm a very new python programmer.

I'm trying to mess around with the mathematical equation, pi, in Jupyter
Notebook which was installed with Anaconda3/Windows 10.

The math package is installed somewhere on my PC because when I try it
in an Anaconda terminal, I get...

     >>> math.pi
     3.141592653589793

I checked the environment...

     >>> import sys; sys.prefix
     'C:\\Program Files\\Anaconda3'

But when I try to run that in a python3 Jupyter Notebook, I get...

     NameError                      Traceback (most recent call last)
     <ipython-input-1-c49acc181da4> in <module>
     ----> 1 math.pi

     NameError: name 'math' is not defined

The error if I start python from a Windows command prompt...

    >>> math.pi
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'math' is not defined

Also, I've been starting Anaconda using the terminal because I don't
need that interface with all those modules. I share Notebook files
(.ipynb) with my Linux Mint laptop through network sharing. So I have a
Linux directory mapped as drive P in Windows...

     >C: cd P:
     >P: jupyter notebook

And I get the shared files in a browser window.

I also tried to run that command (math.pi) from a Jupyter Notebook
started from the Anaconda application and I got the same error.


More information about the Tutor mailing list