Last modified: Jun 23, 2025 By Alexander Williams

How to Uninstall PyMongo in Python

PyMongo is a Python library for MongoDB. Sometimes, you may need to uninstall it. This guide will help you remove PyMongo cleanly.

Why Uninstall PyMongo?

You might need to uninstall PyMongo for many reasons. Maybe you want to upgrade it. Or you no longer need it.

Uninstalling old versions can prevent conflicts. It also helps keep your Python environment clean.

Check If PyMongo Is Installed

First, check if PyMongo is installed. Use the pip list command in your terminal.


pip list

Look for PyMongo in the output. If it's there, note the version.


Package    Version
---------- -------
PyMongo    4.3.3

Uninstall PyMongo Using Pip

The easiest way to uninstall PyMongo is with pip uninstall. Run this command.


pip uninstall pymongo

You will see a confirmation prompt. Type y and press Enter.


Proceed (y/n)? y

Verify the Uninstallation

After uninstalling, verify PyMongo is gone. Run pip list again.


pip list

PyMongo should not appear in the list. If it does, try uninstalling again.

Uninstall Specific PyMongo Version

To uninstall a specific version, use this command.


pip uninstall pymongo==4.3.3

Replace 4.3.3 with your version. This ensures the correct version is removed.

Force Uninstall PyMongo

If normal uninstall fails, use the --force flag. This forces removal.


pip uninstall pymongo --force

Be careful with force uninstall. It may leave residual files.

Clean Up Residual Files

Sometimes, files remain after uninstall. Check these directories.

  • /usr/local/lib/python3.10/site-packages/
  • ~/.local/lib/python3.10/site-packages/

Delete any PyMongo folders or files manually.

Reinstall PyMongo If Needed

If you uninstalled PyMongo by mistake, reinstall it easily.


pip install pymongo

This will install the latest version. For a specific version, add ==version.

Common Issues and Fixes

Here are some common issues and how to fix them.

Permission Denied Error

If you see a permission error, use sudo.


sudo pip uninstall pymongo

Be cautious with sudo. It gives admin privileges.

PyMongo Still Appears After Uninstall

If PyMongo still appears, try restarting your terminal. Or check multiple Python environments.

Uninstall PyMongo in Virtual Environment

If you use a virtual environment, activate it first.


source venv/bin/activate
pip uninstall pymongo

This ensures PyMongo is removed from the virtual environment only.

Conclusion

Uninstalling PyMongo is simple with pip uninstall. Always verify the removal. Clean up residual files if needed.

For other uninstall guides, check How to Uninstall SQLAlchemy in Python or How to Uninstall PyPDF2 in Python.

Keep your Python environment clean. Happy coding!