question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: TypeError: 'NoneType' object is not callable

See original GitHub issue

Describe the issue:

Use sample.zip to run the example

I need to know whether this is a numpy issue or a cython issue or pycharm’s. The error only happens in pycharm debugger under ambiguous circumstances, and it is a known issue. There are mentions that it’s a cython issue despite the failure occurring in numpy/core/getlimits.py Line 649. I need to know where the problem originates and if it’s a numpy issue, is there some merged fix?

Update: The error is gone after building cython with the fix, numpy, pandas, and scikit-learn

Reproduce the code example:

import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer

df = pd.read_parquet('sample.parquet')
corpus = df[df['cell_type'] == 'markdown']['source']
vec = CountVectorizer(ngram_range=(1, 1))
vec.fit(corpus)

Error message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/numpy/core/getlimits.py", line 649, in __init__
    self.dtype = numeric.dtype(int_type)
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 1491, 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/user/Library/Application Support/JetBrains/PyCharm2022.1/scratches/scratch_3.py", line 7, in <module>
    vec.fit(corpus)
  File "/usr/local/lib/python3.10/site-packages/sklearn/feature_extraction/text.py", line 1283, in fit
    self.fit_transform(raw_documents)
  File "/usr/local/lib/python3.10/site-packages/sklearn/feature_extraction/text.py", line 1330, in fit_transform
    vocabulary, X = self._count_vocab(raw_documents, self.fixed_vocabulary_)
  File "/usr/local/lib/python3.10/site-packages/sklearn/feature_extraction/text.py", line 1224, in _count_vocab
    if indptr[-1] > np.iinfo(np.int32).max:  # = 2**31 - 1
  File "/usr/local/lib/python3.10/site-packages/numpy/core/getlimits.py", line 651, in __init__
    self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable
python-BaseException

NumPy/Python version information:

python: 3.10.4
numpy: 1.22.3

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Mark-BCcommented, Jul 15, 2022

I had this same problem: Using PyCharm, but only if running In debug mode, executing

my_dtype = numpy.core.numeric.dtype(numpy.int32)

would cause

TypeError: ‘NoneType’ object is not callable

I solved it by upgrading Pandas from 1.4.2 to 1.4.3

1reaction
ghostcommented, May 21, 2022

I can confirm, the error is gone after building scikit-learn, pandas

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python NoneType object is not callable (beginner)
I faced the error "TypeError: 'NoneType' object is not callable " but for a different issue. With the above clues, i was able...
Read more >
TypeError: 'NoneType' object is not callable in Python
The Python "TypeError: 'NoneType' object is not callable" occurs when we try to call a None value as if it were a function....
Read more >
TypeError: 'NoneType' object is not callable : PY-52137
Debugger fails with numpy getlimits : TypeError: 'NoneType' object is not callable. Hello, I've found a bug that only comes up when run...
Read more >
TypeError: 'NoneType' object is not callable : r/django - Reddit
The first error is that self.model is not defined, so you can't call it. Replace it with CustomUser or (better) the result of...
Read more >
Can't figure out what the problem is - Codecademy
It is giving me a 'NoneType' object is not callable error and I can't seem to ... NoneType is the type of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found