Typeerror must be real number not str
The TypeError: must be real number, not str error concerned with using a wrong type and a non-real number, particularly an str type. When working with Python projects, this is …
itsourcecode.com hosts 220+ documented fixes for Python and JavaScript TypeErrors: the most common runtime error class for both languages. Whether you hit TypeError: 'NoneType' object is not subscriptable in Python or Uncaught TypeError: Cannot read property 'map' of undefined in Node.js, you’ll find the exact error with a step-by-step fix below. Each post explains why the error happens, shows a minimal reproduction, and gives 2-4 ways to fix it. Browse by error family or search the archive for your specific error message.
What is a TypeError?
A TypeError is raised when an operation or function is applied to a value of the wrong type. In Python, the interpreter raises TypeError with a message like “unsupported operand type(s) for +: ‘int’ and ‘str'”. In JavaScript, the runtime throws TypeError with messages like “Cannot read property X of undefined” or “X is not a function”. TypeErrors are the most common runtime exception in both languages because both are dynamically typed, variables don’t declare their type, so type mismatches only surface at execution.
How to debug any TypeError in 4 steps
Read the full message: it usually names both types involved (e.g., “int and str”, “NoneType and dict”). The mismatch is your clue.
Find the exact line: Python tracebacks point to the line; JavaScript stack traces point to the file and line. Look at the variable on that line.
Print the type: add print(type(variable)) in Python or console.log(typeof variable, variable) in JavaScript before the failing line. This tells you what type the variable actually is at runtime.
Trace where the type went wrong: if your variable is None or undefined when you expected a list/object, walk backwards through the code until you find where it got the wrong value (usually a function returning None instead of a list, or an async response that hasn’t resolved).
Featured TypeErrors by error family
The 220+ errors in this archive group into a few common families. Jump to your family below.
🟦 JavaScript: “Cannot read property X of undefined / null”
The most common JavaScript TypeError. You’re trying to access a property on a value that’s undefined or null, usually an unawaited promise, a missing object field, or a state variable that hasn’t been initialized yet.
Cannot read property ‘map’ of undefined (Node.js)
Cannot read property ‘id’ of undefined
Cannot read property ‘replace’ of undefined
Cannot read property ‘createevent’ of null
Cannot read property ‘testEnvironmentOptions’ of undefined
🟦 JavaScript: “X is not a function”
You’re calling something that exists but isn’t a function, usually because you imported the wrong thing, a library API changed between versions, or you destructured an object incorrectly.
res.status is not a function (Express.js, 2026 Guide)
data.map is not a function
e.indexOf is not a function
fsevents.watch is not a function
loaderContext.getOptions is not a function
🟦 JavaScript: “X is not a constructor”
You’re calling new X() on something that isn’t a constructor function, usually a default vs named import mistake or an old library version.
Three.js OrbitControls is not a constructor (2026)
🟢 Python: “‘X’ object is not callable”
You’re treating a non-function as a function (calling it with parentheses). Common causes: shadowing a built-in name (list, str, dict) with a variable, or accidentally using = instead of ==.
‘str’ object is not callable
‘index’ object is not callable
numpy.float64 object is not callable
‘classmethod’ object is not callable
‘collections.OrderedDict’ object is not callable
🟢 Python: “‘X’ object is not subscriptable”
You’re using square-bracket indexing (x[0]) on a value that doesn’t support indexing. Most commonly happens with None, methods, or values that look like collections but aren’t.
‘NoneType’ object is not subscriptable
‘bool’ object is not subscriptable
method object is not subscriptable
‘dict_keys’ object is not subscriptable
‘builtin_function_or_method’ object is not subscriptable
‘AxesSubplot’ object is not subscriptable (matplotlib)
🟢 Python: NoneType errors (14 distinct messages)
A function returned None when you expected a value. Almost always caused by forgetting to return something, an unsuccessful API call, or chaining operations on a function that doesn’t return.
‘NoneType’ object is not subscriptable
‘NoneType’ object does not support item assignment
unsupported operand type(s) for int and NoneType
NoneType can’t be used in ‘await’ expression (Python async)
unsupported format string passed to NoneType.__format__
🟢 Python: “Object of type X is not JSON serializable”
You’re calling json.dumps() on a value that JSON doesn’t know how to encode, usually a NumPy/Pandas type, a datetime, or a custom class. Fix by converting first or providing a custom encoder.
Object of type X is not JSON serializable, 2026 Guide
Object of type DataFrame is not JSON serializable (pandas)
Object of type float32 is not JSON serializable (numpy)
Object of type Response is not JSON serializable
Object of type TextIOWrapper is not JSON serializable
🟢 Python: “unsupported operand type(s) for X”
You used an operator (+, -, *, etc.) between two values whose types don’t combine that way. Most common: adding str + int, or anything involving None.
unsupported operand type(s) for str and float
unsupported operand type(s) for int and NoneType
unsupported operand type(s) for NoneType and NoneType
unsupported operand type(s) for NoneType and str
unsupported operand type(s) for builtin_function_or_method and int
🟢 Python: “missing N required positional argument(s)”
You called a function or method without providing all required arguments. Common when calling methods on classes you forgot to instantiate (e.g., MyClass.method() instead of MyClass().method()).
Missing 1 required positional argument
fit() missing 1 required positional argument: y (sklearn)
dump() missing 1 required positional argument: fp
2026 Updated Guides: featured TypeError fixes
These guides were rewritten or expanded in May 2026 with current library versions, minimal reproductions, and 3-4 alternative fixes each. Start here if your error is in the list.
TypeError: res.status is not a function: Express.js 5 migration
TypeError: Object of type X is not JSON serializable: Python json module
TypeError: Object of type DataFrame is not JSON serializable: pandas
TypeError: Object of type float32 is not JSON serializable: NumPy
TypeError: Object of type float has no len(): Python
TypeError: cannot pickle ‘_thread.lock’ object: Python multiprocessing
TypeError: cannot pickle ‘_thread.RLock’ object: Python multiprocessing
TypeError: ‘AxesSubplot’ object is not subscriptable: matplotlib
TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’: Python comparisons
TypeError: Column is not iterable: pandas/PySpark
TypeError: unhashable type: ‘Series’: pandas
TypeError: unsupported format string passed to numpy.ndarray.__format__
TypeError: unsupported format string passed to NoneType.__format__
TypeError: bad operand type for unary +: ‘list’
TypeError: NoneType can’t be used in ‘await’ expression: async
TypeError: The truth value of a Series is ambiguous: pandas
TypeError: can’t subtract offset-naive and offset-aware datetimes: Python datetime
TypeError: THREE.OrbitControls is not a constructor: Three.js
TypeErrors by library / framework
Library-specific TypeErrors that appear repeatedly in the archive, bookmark this section if you work in any of these stacks.
pandas: Object of type DataFrame is not JSON serializable · The truth value of a Series is ambiguous · unhashable type: ‘Series’ · Column is not iterable · ‘AxesSubplot’ object is not subscriptable
NumPy: Object of type float32 is not JSON serializable · unsupported format string passed to numpy.ndarray.__format__ · numpy.float64 object is not callable
scikit-learn: fit() missing 1 required positional argument: y
matplotlib: ‘AxesSubplot’ object is not subscriptable
Three.js: THREE.OrbitControls is not a constructor
Express.js: res.status is not a function
Node.js: fsevents.watch is not a function · loaderContext.getOptions is not a function · Cannot read property ‘map’ of undefined
asyncio / async: NoneType can’t be used in ‘await’ expression
multiprocessing: cannot pickle ‘_thread.lock’ object · cannot pickle ‘_thread.RLock’ object
Related error categories
TypeError is one of 10 hubs in our Python & JavaScript error reference cluster, 980+ documented fixes total. If your error isn’t a TypeError, jump to the right hub below:
ModuleNotFoundError Reference, 198+ Python “No module named X” import errors
AttributeError Reference, 173+ “object has no attribute X” fixes (NoneType, pandas, NumPy, sklearn)
ValueError Reference, 100+ library-specific Python ValueError fixes (pandas, NumPy, sklearn, TensorFlow)
ImportError Reference, 67+ “cannot import name X from Y” version-conflict fixes
NameError Reference, 49+ Python “name X is not defined” fixes (numpy, pandas, Jupyter)
RuntimeError Reference, 49+ PyTorch CUDA, asyncio, Flask context errors
SyntaxError Reference, 48+ Python & JavaScript parsing errors
ReferenceError Reference, 34+ JavaScript “is not defined” fixes (Node ESM, SSR, React)
HTTP Error Reference, 35+ HTTP 4xx & 5xx status code fixes
Python Tutorial, beginner-to-intermediate Python lessons
About this TypeError reference
This TypeError reference has been built since 2015 by PIES Information Technology Solutions in Binalbagan, Negros Occidental, Philippines. Each post in the collection comes from a real error encountered in production code, by us, by our clients, or by readers who emailed us with their tracebacks. Used by 12,000+ developers and students monthly across the Philippines, India, the United States, and beyond. If your TypeError isn’t here, send the full error message and traceback to our contact form and we’ll add it.
The TypeError: must be real number, not str error concerned with using a wrong type and a non-real number, particularly an str type. When working with Python projects, this is …
Have you ever tried to serialize a response object from a web API using JSON, only to be met with “TypeError object of type response is not JSON serializable” error? …
As a Python programmer, one of the common error you may encounter is TypeError: can only concatenate list (not “int”) to list. This error message usually occur when you are …
Are you stuck to this “typeerror: res.json is not a function” error message while doing your program? And so, continue reading to fix this error. In this article, we’ll hand …
Are you looking for a solution to fix the error message “Typeerror sequence item 0 expected str instance int found” in your code? Then you are in the right place. …
In Python, coming across errors like typeerror: cli.ismultiplecompiler is not a function is possible. Understanding the error you are facing is the first step to fixing it. In this article, …
If you are a Python programmer that encountered the error message “TypeError: Index is not a valid DatetimeIndex or PeriodIndex“, you know how troublesome it can be. This error usually …
Are you dealing with “typeerror: unhashable type: ‘dataframe’” error message and don’t know how to fix? In this article, we will delve into the solutions of “unhashable type: ‘dataframe’” error …
When working with Python projects, we may come across an error that says Typeerror object supporting the buffer api required. At first glance, this error can seem cryptic and frustrating. …
In Python, running into errors like typeerror: ‘nonetype’ object is not subscriptable is unavoidable. Knowing that errors are unavoidable, we should also be mindful that understanding them is the first …
For today’s discussion, we will walk you through fixing this “typeerror: ‘classmethod’ object is not callable.” If you don’t have any idea how to fix this error, keep on reading! …
In this article, we are going to explore the “typeerror: failed to construct ‘url’: invalid url” error message. If this error gives you a headache then you must continue reading. …
Do you want to know how to solve Uncaught TypeError: vue is not a constructor? Read this article for you to understand this error and know how to fix it. …