'No module named 'gmail' even though I installed the module

I ran the below code and got the 2nd below error.

import gmail
try:
    g = gmail.login('[email protected]', 'password')
    if g.logged_in:
        print('Mail log in success')
    g.logout
except gmail.AuthenticationError:  # could not log in
    print('log in fail')
Traceback (most recent call last):
  File "C:\Users\myname\PycharmProjects\projectname\main.py", line 1, in <module>
    import gmail
ModuleNotFoundError: No module named 'gmail'

These are the lists I tried, but didn't work.

  1. I tried changing the configuration interpreter and now I am using the installed python(3.10).
  2. Gmail module is actually installed. https://github.com/kriskavalieri/gmail I double-checked this one.
  3. I reinstalled the oackage "gmail" even inside the pycharm, but then it says
AttributeError: 'module' object has no attribute to 'login'.

Can anyone help me? I almost spent 2 hours and got to the original point.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source