Importerror: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc’

If you are a Python developer and working with AWS SDK, you might have encountered the “ImportError: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc‘” error at some point.

Actually this error can be frustrating and confusing, especially when you are in the middle of developing a critical project.

So in this article, we will explore how to fix it.

What is Importerror: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc’?

The importerror: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc’ error when there is an incompatibility of awscli version in AWS build.

In particular, docevents is a module of botocore library which is part of AWSCLI distribution.

How to fix Importerror: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc’?

Here are some steps you can take to resolve the issue:

  1. Check the spelling of the module and package names to make sure they are correct.

  2. Upgrade your version of botocore using the following command.

    Run the following command to upgrade the botocore package to the latest version:

    pip install –upgrade botocore

  3. Uninstall and reinstall botocore package

    If upgrading botocore doesn’t work, try uninstalling and reinstalling the package using the following commands:

    pip uninstall botocore
    pip install botocore

  4. Make sure that you have the latest version of pip installed.

    You can upgrade pip using the following command:

    pip install –upgrade pip

  5. Change the Import Statement

    If you are unable to update or use an older version of Botocore, you can change the import statement to avoid importing the “docevents” module.

    Instead of using the following import statement:

    from botocore.docs.bcdoc.docevents import DocumentStructure

    You can use the following import statement:

    from botocore.docs.bcdoc import DocumentStructure

Another tips to fix this Error

As a mentioned cause, here are other tips to fix this error.

One of these is to upgrade both packages in particular, awscli and botocore.

sudo python3 -m pip3 install awscli
sudo python3 -m pip3 install botocore

Alternatively, we also need to upgrade pip package manager. This will resolve most of the problems in Python versioning.

So here is the command you can use:

python3 -m pip install --upgrade pip

Usually, any pip install command automatically uninstalls the previous version.

But in some real cases, it will not uninstall the previous package.

So this time, we should manually uninstall the package using the command –

pip uninstall botocore

Now you can try the above command for installing the package botocore module.

Anyway, here are other fixed errors you can consider when somehow you might encounter them.

Conclusion

The “ImportError: cannot import name ‘docevents’ from ‘botocore.docs.bcdoc‘” error can be frustrating, but it is usually easy to fix.

Updating Botocore to the latest version or using an older version that still has the “docevents” module should solve the problem.

If neither of these options are feasible, you can change the import statement to avoid importing the “docevents” module.

Remember to always keep your dependencies up-to-date and double-check the import statements in your code to avoid such errors.

If you found this article helpful, please share it with others who may be experiencing the same issue.

I hope this article has helped you fix the error.

Until next time! 😊

Frequently Asked Questions

What is Python ImportError and what causes it?

ImportError is raised when an import fails for any reason. The most specific subtype is ModuleNotFoundError (no such module). Plain ImportError typically means the module exists but a name inside it can’t be imported, e.g. ‘cannot import name X from Y’ (X was renamed, removed, or moved between versions of Y). Common with library version mismatches.

How do I fix ‘cannot import name X from Y’?

Three steps: (1) Check the library version: pip show Y. (2) Check the changelog of Y, X may have been renamed or removed in a recent release. (3) Either pin to an older Y version (pip install Y==1.x.y) or update your code to the new import path. Common 2025-2026 examples: Werkzeug url_decode removed, Pillow ANTIALIAS renamed to LANCZOS.

Why does the import work in REPL but fail in script?

Two reasons. (1) Different Python interpreter: REPL uses one Python, your script uses another. Run python –version both times. (2) Different working directory: REPL is started where you have access to local modules, script is run from a different cwd. Add the project path to sys.path or use python -m to run as a module.

How do I avoid circular import errors?

Circular imports happen when module A imports B and B imports A at the top level. Three fixes: (1) Move one import inside the function that uses it (lazy import). (2) Restructure code so A and B both import from a third module C. (3) Use TYPE_CHECKING for type-hint-only imports: if TYPE_CHECKING: from a import X.

Where can I find more ImportError fixes?

Browse the ImportError reference hub for 67+ specific fixes (Flask, Werkzeug, Django, ML library versions). For missing-module cases see ModuleNotFoundError. For Python setup help see Python Tutorial hub.

Glay Eliver

Programmer & Technical Writer at PIES IT Solution

Glay Eliver is a programmer and writer at PIES IT Solution, author of over 600 tutorials at itsourcecode.com. Specializes in JavaScript tutorials, Microsoft Office how-tos (Excel, Word, PowerPoint), and Python error debugging covering ImportError, TypeError, AttributeError, ModuleNotFoundError, and JavaScript ReferenceError. Authored several of the site’s highest-traffic Excel and MS Office reference articles.

Expertise: JavaScript · MS Excel · MS Word · MS PowerPoint · Python · Python ImportError · Python TypeError · Python AttributeError · ModuleNotFoundError · JavaScript ReferenceError · Pygame  · View all posts by Glay Eliver →