Reputation: 1379
I am running the following Python code in PyCharm debug mode.
import numpy as np, pandas as pd, numpy.polynomial.chebyshev as chebyshev
from pathlib import Path
home = str(Path.home())
directory = '/Downloads'
d = pd.read_csv(home+directory+'/data.csv')
np.random.seed(0)
nData = 4
data = np.random.randn(nData,2)
z = data[:,0]
y = data[:,1]
coef = chebyshev.chebfit(z,y,3)
I encounter the following error message :
TypeError: 'NoneType' object is not callable
However if I comment out the line 'd = ...', everything works fine. What is even more bizarre is that both versions run well in the run mode. What is happening here?
Stack trace for the error:
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support=auto --client 127.0.0.1 --port 65032 --file /Users/PycharmProjects/pythonProject/trial.py
warning: PYDEVD_USE_CYTHON environment variable is set to 'NO'. Frame evaluator will be also disabled because it requires Cython extensions to be enabled in order to operate correctly.
/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py:1844: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
dummy_thread = threading.currentThread()
Connected to pydev debugger (build 212.5457.59)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/getlimits.py", line 384, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/PycharmProjects/pythonProject/trial.py", line 16, in <module>
coef0 = chebyshev.chebfit(z0,y0,4)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/polynomial/chebyshev.py", line 1670, in chebfit
return pu._fit(chebvander, x, y, deg, rcond, full, w)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/polynomial/polyutils.py", line 650, in _fit
rcond = len(x)*np.finfo(x.dtype).eps
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/getlimits.py", line 387, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Process finished with exit code 1
Upvotes: 11
Views: 5614
Reputation: 2364
Please upgrade to pandas >= 1.4.3 to fix this problem. You'd need to downgrade to Python 3.9, or upgrade to pandas 1.4.3.
This was a real bug (as of 2022-04-14), and was fixed by:
Upvotes: 14
Reputation: 3164
This answer is great. But it should be updated.
Upgrade Pandas --> v1.4.3
You should upgrade to v1.4.3
of pandas. Then the code now behaves as expected in the debugger.
Upvotes: 6