I have three python 2.7 files edit in Spyder 3.1.4 in Anaconda 4.3.1
(1). TestClass.py :Just define a class
import numpy as np
class TestClass:
def getArray(self):
return np.zeros((3,4));
(2). a1.py
from TestClass import *;
tt=TestClass();
(3). a2.py
#just a empty python file
When I "runfile" "a1.py" in Spyder, a TestClass instance tt was created, and I run following code in Spyder's IPython console:
tt.getArray()
Out[9]:
array([[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.]])
It works correctly, but after I runfile a2.py (a empty file) in Spider, and I re-run "tt.getArray()" in Spyder's IPython console, the error occours:
tt.getArray() Traceback (most recent call last):
File "", line 1, in tt.getArray()
File "TestClass.py", line 6, in getArray return np.zeros((3,4));
AttributeError: 'NoneType' object has no attribute 'zeros' the numpy became missing, in my experience any "runfile" operator in Spyder will lead to missing numpy. Any code about "tt" can't not write in a2.py because tt alread imported package are missing when run a new file. Is this a bug ? Or Spyder, Ipython need further configure or set parameter? Or "runfile" command in spyder need additional paramter?
I have go mad with this error, please tell me where I went wrong.