我需要安装 python 的 customtkinter 包。
我使用命令
pip install customtkinter
来安装该软件包。
运行 pip list
时,我可以看到 customtkinter
软件包版本。
在 pycharm 编辑器中,要导入的包接缝:
Traceback (most recent call last):
File "C:\Users\tal.d\PycharmProjects\py1.py\venv\1.py", line 1, in <module>
import customtkinter
ModuleNotFoundError: No module named 'customtkinter'
我做错了什么?
对于Python 3。
pip3 install customtkinter
更新现有安装:
pip3 install customtkinter --upgrade
您不能只 pip install customtkinter。但首先请确保 pycharm 配置正确。如果其他 pip 包可以工作,那么这个也应该可以工作。 假设您有 python 3,您需要打开命令提示符并输入以下命令:
安装customtkinter:
pip3 install customtkinter
安装包装:
pip install packaging
然后您应该能够像其他软件包一样将 customtkinter 导入到您的程序中来使用它。
我有这个问题,解决这个问题的方法是在首选项中添加customtkinter,就像添加主题一样。
Settings (ctl+alt+s) --> Click your project on the left --->Click python interpreter ---> Click the "+" button ---> search 'customtkinter' --> click install
之后只需修复我的大小写错误即可让程序运行。
如果您安装了 Anaconda 和 Python,则需要选择全局解释器,即不是 Anaconda 3。切换解释器
我强烈建议您确保使用虚拟环境(Virtualenv)。当您在 Pycharm 中创建新项目时,您将获得该选项。此时您还应该能够选择基本的 Python 解释器。
单击“创建”,然后让 Pycharm 完成它的工作。
接下来转到“文件”->“设置”并展开指向您的项目名称的链接(就在“版本控制”下方)。
现在单击 Python Interpreter,您将看到一个包含已安装模块的显示(您应该看到列出的 pip 和其他一些模块)。模块列表上方有一个 + 图标。
单击该按钮,将出现一个弹出窗口。在顶部的搜索字段中输入 customtkinter。您应该会看到列出的模块。用鼠标选择它,然后单击对话框底部的安装包。
请留意任何错误。
安装软件包后,您就可以开始了。
您还可以检查位于项目文件夹中的 venv 目录。如果您从“venv > lib > PythonX.YY > site-packages”向下钻取,您应该会看到一个 customtkinter 文件夹。我认为在 Windows 上,PythonX.YY 不包含在路径中,所以会是这样的:
“venv > lib > 站点包”
哦,正如另一个回复中所建议的,我会避免使用 Anaconda。当涉及到 CustomTkinter 时,似乎可能存在一些问题。
你可以尝试做
python3 -m pip install customtkinter
您也可以使用
pip3 install customtkinter
而不是
pip install customtkinter