python,

Resolve: "No module named <insert-package-name-here>" in Python

Nov 22, 2022 · 1 min read · Post a comment

Building and compiling Python apps could be troublesome chiefly when copy-and-pasting another code from the internet without installing or importing the module itself. Sound familiar?! Here’s a nugget for any other error being: No module named <package-name> here as the common one-size-fits-all solution.

Prerequisites

  • Python 3
  • pip

Solution

Step 1. cd to your Python project virtual env directory.

Related: Create, manage and remove virtual environments in Python.

Step 2. Install the required missing module.

pip install --upgrade <insert-package-name-here>

Note(s):

  • If the above command doesn’t work, try adding sudo in front.
  • Or, even replace pip with pip3.
  • Make sure to check in case the module is already deprecated.

Conclusion

Related posts:

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.