如何在Pycharm virtualenv中使用tkinter?

问题描述 投票:0回答:1

我成功安装了tkinter但是当我在pycharm中运行我的程序时仍然出现错误。如果我从终端运行它,它工作正常。

我收到此错误:

ModuleNotFoundError:没有名为'tkinter'的模块

我有一种感觉,我必须以某种方式告诉我的Pycharm虚拟环境,它需要包含tkinter。这在设置 - >项目解释器中不可用。

我在Linux Mint btw,我使用python3.7。

python tkinter pycharm
1个回答
0
投票

如果您使用的是虚拟环境,则需要找到相应虚拟环境的Python位置,然后使用source命令激活虚拟环境。

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000639400-Activating-virtual-environment-in-Pycharm-python-console

enter image description here

# active virtualenv 
source virtualenv_path/bin/activate

© www.soinside.com 2019 - 2024. All rights reserved.