cannot import name 'messagebox' from 'tk'Error

You don't need to install tkinter or base64 separately at all, they're both built-in. (If Tkinter support hasn't been built in to your Python installation, you will need to rebuild Python with Tkinter support, you can't just install it separately.)

  • If you have indeed done pip install tk, then you will have installed this package that is unrelated to tkinter. You'll want to uninstall it.
  • Similarly, you don't need pybase64 to do base64 operations. Best uninstall it too.
  • Thirdly, make sure your script isn't called tk.py itself.
  • Finally, as mentioned above, the module is tkinter, not tk. It's just common to do import tkinter as tk for brevity.
    • Also, using * imports is generally not a good idea; you'll find your namespace polluted with all sorts of symbols you won't need or know where they're from.

try to import tkinter, from tkinter import messagebox you can also do the same with the rest of the imports

from tkinter import * as tk
import pybase64
from tkinter import messagebox