Name pd is not defined


#1

Hello Research Dept,

I’m a newbie so please bear with me. I have a Windows 10 laptop (Anaconda3 is installed) and I have installed Atom and a few packages:

Hydrogen
file-icons
project-manager

Basically, I’m trying to achieve what Alvaro did in this short blog:

I have included a snap shot of my test.py file and the error “name pd is not defined:”

Can you give me any suggestions as to what I need to do so Atom can find maplotlib, numpy and pandas? Where does Atom look when it imports these packages? How can I tell it where they are?

Thanks,

David


#2

I feel like the problem is probably that Hydrogen thinks you want to run that line, so that’s all it sends to the interpreter. Can you try running the whole page at once?

Atom doesn’t look anywhere and doesn’t know anything. The Python interpreter (in this case iPython, since you’re using Hydrogen) is looking. Or not looking, in this case, because it doesn’t know that anything needs to be imported.


#3

I installed the script package in Atom, and if I start Atom from the command line with ‘atom test.py’ from my Anaconda Prompt I can run test.py in Atom by typing ctrl-shift-b. It executes the entire program, But if I just click on Atom from windows and try to do ctrl-shift-b i get the error ‘python is not recognized…’. Hydrogen is still not working, though; it is supposed to execute the pandas and the plt lines “inline” the way Jupyter Notebooks does. Hydrogen pops up a window when I click on the pandas line and this shift-enter saying that it is updating the Hydrogen kernels:

image

Hydrogen is supposed to show the pandas dataframe inline and the matlibplot inline, and I suppose Hydrogen requires iPython to do that and it can’t get to it because of some missing configuration in the PATH variable or something like that. I’m wanting to understand the sequence of events going on under the hood so I can fix this. Thanks!


#4

Because your system doesn’t know where Python is, but the environment of the Anaconda prompt does.

I’ve never used Anaconda, so I just installed it. I believe the first checkbox on this screen is the one you can check in order to access Anaconda’s python command outside of Anaconda.

To do it manually, you just add the Anaconda3/ folder path to your PATH variable. python.exe is right in the top level of that folder.

Hydrogen is still not working, though; it is supposed to execute the pandas and the plt lines “inline” the way Jupyter Notebooks does.

It might just execute the line(s) you send it and display the results inline. But I’ve never used Hydrogen so I know nothing about how it works.


#5

It has several ways to run, including this. It sounds like the most likely cause.


#6

I added c:\Anaconda3 to my PATH variable and I can execute the whole test,py program when opening atom from windows. Hydrogen works for lines other than the pandas line and the matplotlib line; for example if you put the cursor next to the line with “17+25” and hit shift-enter you will see 42 next to that line. However, if you place the cursor next to the pandas line you will get “name pd is not defined.” For some reason Hydrogen can’t find pandas or matplotlib or numpy. It could be an issue with the required kernels. I think that there is an ipykernel and Hydrogen might not be picking it up for some reason. I don’t know, I’m just putting that out there.


#7

Did you run the line to import pandas? Simple math will run fine without any imports.


#8

Thank you, Aerijo!! I placed the cursor on each import line and hit shift-enter and a check mark came up by each one. Then I was able to run the pandas line. I highlighted all the lines for the plot and it displayed inline as well! Here is a screen shot of as much of the file as I could get:

Thanks Scholar! Thanks Aerijo!