Tkcalendar已正确安装,但仍然显示“找不到模块”错误

时间:2019-12-07 09:41:14

标签: python python-3.x anaconda tkcalendar

我通过pip正常安装了tkcalendar,并且一切安装正常:

C:\Users\Pavel>python -m pip install tkcalendar
Collecting tkcalendar
  Downloading https://files.pythonhosted.org/packages/44/18/2d6a50fd9703a4cf96a24d12aee5a21b33e75d0b3e6b25fa4dcd7d06efc1/tkcalendar-1.5.1-py3-none-any.whl
Collecting babel (from tkcalendar)
  Downloading https://files.pythonhosted.org/packages/2c/60/f2af68eb046c5de5b1fe6dd4743bf42c074f7141fe7b2737d3061533b093/Babel-2.7.0-py2.py3-none-any.whl (8.4MB)
     |████████████████████████████████| 8.4MB 6.4MB/s
Requirement already satisfied: pytz>=2015.7 in c:\users\pavel\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (from babel->tkcalendar) (2019.3)
Installing collected packages: babel, tkcalendar
Successfully installed babel-2.7.0 tkcalendar-1.5.1

但是,当我尝试运行脚本时,出现一个找不到模块的错误:

 File "C:/Python_working/exercies/tkinter.py", line 7, in <module>
    from tkcalendar import Calendar, DateEntry

ModuleNotFoundError: No module named 'tkcalendar'

我尝试重新启动Spyder,并尝试使用pip重新安装,但只收到一条消息,提示已安装软件包。

最后,我尝试使用conda安装软件包,但是在这里出现以下错误:

PackagesNotFoundError: The following packages are not available from current channels:

  - tkcalendar

不确定要解决此问题的其他方法。

使用Python 3.7和Spyder 3.3.6。

更新: 从命令提示符运行python,然后运行import tkcalendar可以正常工作。

我在github上发现了this guide to working with virtual environments in Spyder,但似乎有点烦人...

1 个答案:

答案 0 :(得分:0)

好吧,好吧...在此post中找到了答案。

基本上,这个想法是,对于不属于常规Spyder / Anaconda安装的软件包,您需要转到工具-> PYTHONPATH并为每个模块添加一个新文件夹。然后重新启动Spyder,一切正常。