2025, Sep 28 15:00

How to Fix ModuleNotFoundError: Use flask_humanify (not flask-Humanify) for the correct Python import

Installed flask-Humanify but get ModuleNotFoundError? Import flask_humanify instead. pip show --files check, plus tips to avoid Python import errors.

Python says the package is installed, yet the import blows up with ModuleNotFoundError. If that sounds familiar, you’re likely hitting a classic mismatch between a distribution name (as shown by pip) and the actual importable module name. Here’s a concise walkthrough of what’s happening with flask-Humanify and how to fix it fast.

Problem statement

You install the package and pip confirms success:

/usr/local/bin/python3.6 -m pip install flask_Humanify

The interpreter and pip are clearly aligned:

/usr/local/bin/python3.6 --version
Python 3.6.3

/usr/local/bin/python3.6 -m pip --version
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

pip list -v
...
flask-Humanify         0.2.3 /usr/local/lib/python3.6/site-packages pip
...

But running the code fails with an import error:

/usr/local/bin/python3.6 test.py

Traceback (most recent call last):
  File "once.py", line 29, in <module>
    from flask_Humanify import Humanify
ModuleNotFoundError: No module named 'flask_Humanify'

Minimal failing example

The import line below reproduces the issue. The local alias is arbitrary and does not affect behavior; the failure is caused by the module path.

# test_app.py
from flask_Humanify import Humanify as HumanifyAlias

Why it breaks

Case matters for imports. The installed distribution is named flask-Humanify, but the importable module is named flask_humanify. That difference is enough to trigger ModuleNotFoundError when using the mixed-case variant with an underscore after Flask. Verifying the installed files makes this obvious. Running a file listing via pip shows the top-level package directory is lowercase with an underscore:

$ py3/scripts/pip show flask-Humanify --files
Name: flask-Humanify
Version: 0.2.3
...
Files:
  flask_humanify-0.2.3.dist-info\INSTALLER
  flask_humanify-0.2.3.dist-info\METADATA
  flask_humanify-0.2.3.dist-info\RECORD
  flask_humanify-0.2.3.dist-info\REQUESTED
  flask_humanify-0.2.3.dist-info\WHEEL
  flask_humanify-0.2.3.dist-info\licenses\LICENSE
  flask_humanify-0.2.3.dist-info\top_level.txt
  flask_humanify\__init__.py
  flask_humanify\humanify.py
  ...

Switching to the correct module name resolves the error immediately. This discrepancy is also reflected in the interactive session below:

>>> from flask_Humanify import Humanify
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'flask_Humanify'
>>> from flask_humanify import Humanify
>>>

It’s easy to be tripped up here because the documentation contains this typo as well, which makes the incorrect form look plausible.

The fix

Import the class from the correct module name, preserving the same functionality. The alias is optional and used here to keep local naming distinct.

# fixed_test_app.py
from flask_humanify import Humanify as HumanifyAlias

How to confirm quickly

If you’re unsure what the import path should be, checking the installed files via pip is a fast way to confirm. The following command was used to surface the module’s top-level package name and verify it’s flask_humanify:

.../pip show --files flask-Humanify

Scanning that output for the package directory name points you to the correct import path.

Why this matters

Confusing the distribution name with the module name is a frequent cause of ModuleNotFoundError, especially when a project uses mixed case or punctuation in one place and a different style in the import path. In this case, the package README contains the mistaken import line, which compounds the confusion. Clearing up the import path saves time and avoids unnecessary environment surgery.

There is also a practical meta-lesson from the installation output: running pip as root is discouraged, and the warning explicitly recommends a virtual environment. While that didn’t cause this particular error, it’s a good reminder for day-to-day Python work.

Takeaways

When Python says a package is installed but the import fails, verify the importable module name rather than the distribution name. For flask-Humanify, the correct import path is flask_humanify, and the class inside it is Humanify. A quick pip show --files check tells you exactly which top-level package directory to import. Pay attention to case, trust what pip reveals about installed files, and prefer a virtual environment as the installer suggests.

The article is based on a question from StackOverflow by carl and an answer by J Earls.