Quick Answer
AttributeError: module 'numpy' has no attribute 'typeDict' usually means legacy code is using a deprecated or removed alias in the installed NumPy version. Check np.__version__, replace lookups with np.sctypeDict when a scalar-type mapping is required, or use explicit np.dtype(...). Update the dependency that still references np.typeDict when possible.

The error module 'numpy' has no attribute 'typeDict' usually appears when older code runs with a newer NumPy release. The old np.typeDict alias was deprecated and later removed, so imports or helper functions that still reference it now fail.
The fix is to update the code that reads NumPy scalar type mappings. In most cases, replace np.typeDict with np.sctypeDict, or avoid the dictionary entirely and use explicit dtype objects such as np.float64, np.int_, and np.bool_.
The NumPy 1.24 release notes explain several removed aliases and compatibility changes. For related cleanup, see the NumPy asscalar replacement guide and how to check your Python version.
This error often appears after a dependency upgrade, notebook migration, container rebuild, or server deploy. The project may have worked for months, then fail as soon as NumPy is upgraded under an older package. That does not mean NumPy is unavailable; it means one piece of code still expects an old public alias.
Before changing versions, find where the name is used. Search your project, then check the traceback to see whether the failing line belongs to your code or to an installed dependency. The right fix depends on who owns that line.
Reproduce The AttributeError
If a package or script still asks for np.typeDict, newer NumPy versions raise an AttributeError.
import numpy as np
try:
print(np.typeDict)
except AttributeError as error:
print(error)
This confirms that the failure is in the deprecated name, not in the NumPy import itself. If import numpy as np works, your environment has NumPy installed.
If the traceback points to a dependency, avoid editing files inside site-packages by hand. Manual edits disappear when the package is reinstalled, and they are hard to reproduce on another machine. Upgrade the dependency or report the compatibility issue upstream.

Use sctypeDict Instead
np.sctypeDict is the direct replacement when code truly needs NumPy’s scalar type dictionary.
import numpy as np
scalar_types = np.sctypeDict
float64_type = scalar_types["float64"]
int64_type = scalar_types["int64"]
print(float64_type)
print(int64_type)
This keeps the same general lookup style while using the supported public name. It is often enough for old helper code that only needs to map names to scalar types.
Use this replacement when the code genuinely needs a flexible lookup by dtype name. If the code always uses the same two or three dtypes, an explicit map is usually clearer and safer.
Prefer Explicit dtype Objects
If you only support a small set of types, an explicit mapping is easier to read than a broad lookup table.
import numpy as np
DTYPE_MAP = {
"float": np.float64,
"integer": np.int_,
"boolean": np.bool_,
}
array = np.array([1, 2, 3], dtype=DTYPE_MAP["float"])
print(array.dtype)
This approach is clearer for application code. It also prevents unexpected names from being accepted just because they exist in NumPy’s full scalar type dictionary.
Explicit dtype objects also make reviews easier. A future reader can see the accepted names immediately instead of tracing a broad dictionary lookup through NumPy internals.

Check The NumPy Version
When debugging dependency issues, print the NumPy version from the same interpreter that runs the failing code.
import numpy as np
from numpy.lib import NumpyVersion
version = NumpyVersion(np.__version__)
if version >= "1.24.0":
print("np.typeDict is not available in this NumPy version")
else:
print("older NumPy version detected")
Version checks are useful for diagnostics, but they should not be the long-term fix. Updating the deprecated attribute is better than pinning NumPy forever.
Still, version output is important when asking for help. Include the Python version, NumPy version, and the package that raised the error. That makes it much easier to identify a known compatibility problem.
Patch A Compatibility Helper
If you maintain a library, wrap the lookup in one helper so old and new NumPy versions are handled in one place.
import numpy as np
def get_scalar_type(name):
scalar_types = getattr(np, "sctypeDict", None)
if scalar_types is None:
raise RuntimeError("NumPy scalar type dictionary is unavailable")
return scalar_types[name]
print(get_scalar_type("float64"))
Do not keep fallback code for removed names longer than necessary. Once your supported NumPy range is modern, simplify the helper and keep the supported path only.
Compatibility helpers are useful during migrations, but they can become clutter if every removed alias stays forever. After your minimum supported NumPy version moves forward, delete the legacy path and keep the code direct.

Update Third-Party Dependencies
Sometimes your own code never references typeDict. The error may come from an old dependency that imports NumPy internally. In that case, update the dependency first.
import importlib.metadata as metadata
for package_name in ["numpy", "pandas", "scipy"]:
try:
version = metadata.version(package_name)
except metadata.PackageNotFoundError:
version = "not installed"
print(f"{package_name}: {version}")
Run this in the same virtual environment, notebook kernel, or deployment container that shows the error. Different environments can have different package versions even on the same machine.
If the dependency is old and unmaintained, consider replacing it or adding a small adapter around the behavior you need. Downgrading NumPy for one stale import can block other packages that expect a modern release.
Best Fix Strategy
Start by finding the exact line that references typeDict. If it is your code, replace it with sctypeDict or an explicit dtype mapping. If it is inside a dependency, update that dependency before changing your NumPy version.
Downgrading NumPy can be a short-term workaround for a locked production system, but it should not be the final repair. Older NumPy versions can miss important bug fixes and may conflict with newer packages.
The reliable pattern is to remove deprecated aliases, use explicit dtype names where possible, and keep package versions aligned. That fixes the immediate typeDict error and makes future NumPy upgrades less fragile.

Choose the Modern Replacement
First identify what the old code needs. For a mapping from names such as float64 to NumPy scalar types, np.sctypeDict is the closer compatibility replacement. If the code needs an array data type, an explicit np.dtype is usually clearer.
import numpy as np
print(np.__version__)
scalar_type = np.sctypeDict["float64"]
dtype = np.dtype("float64")
print(scalar_type, dtype)
Do not rely on a private NumPy module as a long-term fix. Prefer public APIs and write a small compatibility helper only when supporting a known range of NumPy versions.
Update the Dependency That Uses typeDict
If the traceback points into another package, the durable fix is usually to update that package to a release compatible with your NumPy version. Pin a known-good pair temporarily if an upgrade is blocked, and test the application before changing production dependencies.
import numpy as np
DTYPE_MAP = {
"float": np.float64,
"integer": np.int64,
"boolean": np.bool_,
}
array = np.array([1, 2, 3], dtype=DTYPE_MAP["float"])
print(array.dtype)
NumPy release notes document deprecations and compatibility changes. Compare those notes with the installed version instead of assuming every environment has the same behavior.
Frequently Asked Questions
Why does NumPy have no attribute typeDict?
The code is using a legacy NumPy alias that is deprecated or removed in the installed version. Check the version and migrate the lookup.
What should replace np.typeDict?
Use np.sctypeDict for a scalar-type mapping or an explicit np.dtype when the program needs a data type object.
How do I check my installed NumPy version?
Import NumPy and print np.__version__, or inspect the environment with python -m pip show numpy.
What if a third-party package still uses np.typeDict?
Update that package to a compatible release, or temporarily pin a tested NumPy version while preparing a proper dependency fix.