[英]PySimpleGui - No module named '_tkinter'
I installed PySimpleGUI and copy/pasted the "Jump-Start" code into vs code.我安装了 PySimpleGUI 并将“Jump-Start”代码复制/粘贴到 vs 代码中。 i tried to run it and it keeps spitting out the error我试图运行它,它不断地吐出错误
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
I have already installed tkinter using我已经安装了 tkinter 使用
sudo apt-get install python-tk python3-tk tk-dev
...help ...帮助
edit: Here's my code:编辑:这是我的代码:
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()
you can follow the steps你可以按照步骤
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
Add to ~/.bashrc添加到 ~/.bashrc
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Reload bashrc重新加载 bashrc
source ~/.bashrc
Install python latest version安装python最新版本
pyenv install 3.7.0
list python versions列出python版本
pyenv versions
set global version设置全球版本
pyenv global 3.7.0
check python version检查python版本
python -V
install PySimpleGUI安装 PySimpleGUI
pip3 install PySimpleGUI
That's it, now you are able to import PySimpleGUI.就是这样,现在您可以导入 PySimpleGUI。
import PySimpleGUI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.