Python 获取错误:没有名为'的模块;日历ui';。尽管KivyCalendar是在windows 10中使用pip安装的

Python 获取错误:没有名为'的模块;日历ui';。尽管KivyCalendar是在windows 10中使用pip安装的,python,calendar,kivy,Python,Calendar,Kivy,KivyCalendar是在windows 10中使用pip安装的。但返回一个错误:- 没有名为“日历”的模块 我的代码是: from kivy.app import App from KivyCalendar import CalendarWidget class MyApp(App): def build(self): return CalendarWidget() MyApp().run() 任何帮助都将不胜感激。谢谢此错误仅在Python 3和Pytho

KivyCalendar是在windows 10中使用pip安装的。但返回一个错误:-

没有名为“日历”的模块

我的代码是:

from kivy.app import App
from KivyCalendar import CalendarWidget


class MyApp(App):

    def build(self):
        return CalendarWidget()

MyApp().run()

任何帮助都将不胜感激。谢谢

此错误仅在Python 3和Python 2.7上发生,一切正常

正如您在模块中看到的,它仅与Python 2.7兼容:

编程语言::Python::2.7


您在这里没有太多的选择:要么使用Python 2.7,要么使用fork项目,并创建与Python 3一起工作的日历。

我在项目中使用KivyCalendar时遇到了一些问题,所以我做了一些改进,使其在Python 3上工作。确保有原始文件的副本

添加行首有+标记的行,删除行首有-标记的文件

首先找到安装kivycalendar的目录

KivyCalendar/init.py

 #!/usr/bin/python
 # -*- coding: utf-8 -*-

 -from calendar_ui import DatePicker, CalendarWidget
 +from .calendar_ui import DatePicker, CalendarWidget
KivyCalendar/calendar\u data.py

-from calendar import TimeEncoding, month_name, day_abbr, Calendar, monthrange
+from calendar import month_name, day_abbr, Calendar, monthrange
 from datetime import datetime
 from locale import getdefaultlocale
+import locale as _locale
+
+
+class TimeEncoding:
+    def __init__(self, locale):
+        self.locale = locale
+
+    def __enter__(self):
+        self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
+        return _locale.getlocale(_locale.LC_TIME)[1]
+
+    def __exit__(self, *args):
+        _locale.setlocale(_locale.LC_TIME, self.oldlocale)
+

 def get_month_names():
     """ Return list with months names """
KivyCalendar/calendar\u ui.py

 from kivy.core.window import Window
 from kivy.properties import NumericProperty, ReferenceListProperty

-import calendar_data as cal_data
+from . import calendar_data as cal_data
 ###########################################################
 Builder.load_string("""
 <ArrowButton>:
从kivy.core.window导入窗口
从kivy.properties导入NumericProperty、ReferenceListProperty
-将日历数据导入为校准数据
+从。将日历数据导入为校准数据
###########################################################
生成器。加载\u字符串(“”)
:

Skucul/datepicker可以很好地与Python 2.7和Python 3配合使用。