Python cannot actually be compiled. Spyder performs just a static code analysis using Pylint. Depending on the version of Pylint that is being used, it could be a bug or an undetectable case for it.
For example, the import
statement (or the path that gets to it) could be within a conditional block, which cannot be resolved until runtime. Given that you are using Spyder, it could also be that you put your import
statement directly on the console, or in a separate file, and then use the imported module from the script.
You may try to see if you receive the same error with a script like the following:
import numpy
QR10 = [1, 2, 3]
QR20 = [1, 2, 3]
QR11 = [1, 2, 3]
QR21 = [1, 2, 3]
QR10 = numpy.array(QR10,dtype=float)
QR20 = numpy.array(QR20,dtype=float)
QR11 = numpy.array(QR11,dtype=float)
QR21 = numpy.array(QR21,dtype=float)
You should not see the E0602
here. Funny enough, however, you may receive [E1101] Module 'numpy' has no 'array' member
, because it turns out that numpy does some dynamic definition of members, so Pylint cannot know about it (as you may see here) of a bug that has actually been solved already.
The moral of the story is that Pylint errors shouldn't keep you awake at night. It's good to see the report, but if you are sure that your code makes sense and it runs just right, you may just ignore them - although trying to know why it is giving an error is always a good exercise.
np.array...etc
, (which I have tested and is not working) now, Spyder comes with the package Python(x,y) so everything (python 2.7, numpy, matplotlib, etc) is installed. When I mentioned that the script works I wanted to mean inside Spyder by clicking "Run", so, even with more than 30 errors when compiling, it works from the beginning to the end without raising any error, even when walking over the lines marked as "Error" in the picture above. That's weird... – codeKiller