Atom hydrogen has problem


#1

I had this error code when I’m using hydrogen package and import numpy, can anyone help me with this situation? I’m a newby in Python.
Thank you very much.


#2

You seem to have made a file called numpy.py and have a syntax error in it.

In general, I recommend not using hydrogen until you get more experience with programming in general. The best thing to to would be running your scripts in the command line; once you get comfortable with that, go for editor integration.

Alternatively, you might like to use the dedicated jupyter tool to have an experience like hydrogen, but more robust (it’s somewhat easier to use in my opinion). If you have Anaconda, it should come bundled (and Anaconda Navigator will give you a GUI to interact with when opening it).


#3

What happens if you rename your file to something other than numpy.py?


#4

As the message says, you have a Python syntax error.

! == should be !=


#5

Yes, but that’s not the whole story. Python isn’t importing the numpy package. It’s importing C:\Users\CMZ\Desktop\python\Python practice\numpy.py, because @IronCMZ is naming all of their code files the same as the main package they’re trying to call. Using distinctive file names should solve the problem that was specifically asked about.


#6

That really works! thank you so much!!
It’s wield because I use this file name all the time, it just comes out suddenly.


#7

Thanks, that helps me a lot!


#8

Under normal circumstances, it shouldn’t happen. It did because the second numpy.py file is somehow in your Python path, which is derived from your system path, plus Python’s own packages, plus wherever you’re running the code. I could tell you more if I knew exactly where the first numpy.py is and how your Python is configured, but my guess is that the first numpy.py is in a folder pretty close to the second numpy.py, such that Python finds your other code file when it looks for numpy and thus stops looking for the package.