[英]PySimpleGui - No module named '_tkinter'
我安装了 PySimpleGUI 并将“Jump-Start”代码复制/粘贴到 vs 代码中。 我试图运行它,它不断地吐出错误
Exception has occurred: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: <module>)
No module named '_tkinter'
File "/home/x/Code/PySimGui/testing_it_out.py", line 1, in <module> (Current frame)
import PySimpleGUI as sg
我已经安装了 tkinter 使用
sudo apt-get install python-tk python3-tk tk-dev
...帮助
编辑:这是我的代码:
import PySimpleGUI as sg
sg.theme('DarkAmber') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text('Some text on Row 1')],
[sg.Text('Enter something on Row 2'), sg.InputText()],
[sg.Button('Ok'), sg.Button('Cancel')] ]
# Create the Window
window = sg.Window('Window Title', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
break
print('You entered ', values[0])
window.close()
你可以按照步骤
curl -L https://raw.githubusercontent.com/yyuu/pyenv- installer/master/bin/pyenv-installer | bash
sudo apt update && sudo apt upgrade
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev git
添加到 ~/.bashrc
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
重新加载 bashrc
source ~/.bashrc
安装python最新版本
pyenv install 3.7.0
列出python版本
pyenv versions
设置全球版本
pyenv global 3.7.0
检查python版本
python -V
安装 PySimpleGUI
pip3 install PySimpleGUI
就是这样,现在您可以导入 PySimpleGUI。
import PySimpleGUI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.