ImportError No module named dateutil.parser
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
ImportError: No module named dateutil.parser usually means one of three things: the python-dateutil package is not installed in the active environment, your script is running under a different interpreter than the one where it was installed, or a local file is shadowing the real package. The import itself is straightforward once the environment is correct. The hard part is usually identifying which Python environment your code is actually using.
The Correct Package and Import
The package you install is called python-dateutil, but the import path is dateutil.
Correct import:
Or:
The error means Python could not resolve that import path in the current runtime.
Install the Package in the Right Environment
The standard fix is:
Using python -m pip is safer than calling plain pip because it ties the installation to a specific interpreter.
For example, if your project uses Python 3 explicitly:
If you are in a virtual environment, activate it first before running the install command.
Confirm Which Interpreter Is Running
A very common problem is that the package is installed, but not in the interpreter your script is using.
Check the interpreter path:
Then check whether the package is installed there:
If those two commands do not line up with the environment your editor, test runner, or application launcher is using, the import error will persist.
Virtual Environment Mismatch
Suppose you installed python-dateutil globally but your app runs in a virtual environment. The global install will not help.
Typical workflow:
If you are using an IDE, also make sure the IDE interpreter is the same .venv interpreter you just configured.
Watch for Local Module Shadowing
Another common cause is naming your own file or folder dateutil.py or dateutil/. That shadows the real installed package.
Problematic structure:
Then app.py may import your local file instead of the package you expected.
You can inspect where Python is resolving the module from:
If the path points to your project directory unexpectedly, rename the conflicting file or folder.
Verify the Import Interactively
Sometimes the quickest test is an interactive one-liner:
If that works, the package itself is fine and the remaining problem is probably how your application is launched.
Dependency Files Matter
If the package is needed by the project, add it to your dependency file rather than only installing it manually.
For example in requirements.txt:
This keeps environments reproducible across machines, CI jobs, and deployments.
Example Failure Diagnosis
A practical diagnosis sequence is:
- check the import statement
- run
python -m pip show python-dateutil - print
sys.executable - inspect whether a local
dateutil.pyexists - retry the import in a one-line command
That sequence usually narrows the issue quickly.
Common Pitfalls
The biggest mistake is installing the package with one interpreter and running the script with another. Another is forgetting that the package name is python-dateutil while the import name is dateutil. Developers also often overlook local files named dateutil.py that shadow the real package. Finally, IDE and notebook environments can use a different interpreter from the one your shell is using, which makes the problem look inconsistent.
Summary
- Install
python-dateutil, but import it asdateutil. - Use
python -m pipso the package is installed into the interpreter you actually run. - Check virtual environments and IDE interpreter configuration.
- Look for local files or folders that shadow the
dateutilpackage. - Verify the import with a simple one-line test before debugging deeper.

