Python - No module named
Error: ModuleNotFoundError: No module named ‘dotenv’
Reason: The virtual environment for Python was not created/set.
Solution:
Create a new python virtual environment: python3 -m venv ~/pythonvenv/
List the contents of the directory and verify the permissions: ls -al ~/pythonvenv/
Install the required module: pip3 install python-dotenv OR python -m pip install {package_name}
Source the new virtual environment: source ~/pythonvenv/bin/activate
Upgrade the Pip: pip install –upgrade pip
This post is licensed under CC BY 4.0 by the author.