ttkbootstrap module not found

321 Views Asked by At

I recently installed pip install ttkbootstrap successfully. I also have tkinter installed and everything works fine when I import it. When I try to import ttkbootstrap into PyCharm it doesnt recognize the module and gives me this error: File "C:\Coding\PyCharm\Projects\Project 1\projectfile.py", line 3, in import ttkbootstrap as ttk ModuleNotFoundError: No module named 'ttkbootstrap'

I've searched other questions and couldn't find an answer to this problem. I was wondering if anyone knows what to do here, I've been struggling with this for a while now, any help would be be really appreciated

2

There are 2 best solutions below

5
On

Every time I create a new project I also create a venv from one of my interpreters on my system.

new pycharm project

In this venv you then install ttkbootstrap in the settings of PyCharm.

pycharm settings install ttkbootstrap

If you want to test if the installation worked you'll have to either use the temrminal inside PyCharm or just use the import statement.

import statement

terminal in pycharm

You can even have multiple run configurations including different python interpreters and as you install them as venv you can have multiple installations of packages in these environments.

debug run configs

Important: If you are running Python 3.12 in PyCharm you'll have to update to the latest version. After this you'll probably have to recreate your venv otherwise it will still not work

0
On

Try this:

script:

from ttkbootstrap import Style 
from tkinter import Tk
import ttkbootstrap as ttk
 

style = Tk() 
window = style.master

ttk.Label(style, text='my label' ).pack()
 
style.mainloop()

Or same module.

root = Tk()

ttk.Label(root, text='my label').pack()

root.mainloop()

Screenshot:

enter image description here