尝试在Python中导入dragonfly时出现“Unknown char”错误

时间:2015-07-31 14:02:39

标签: python python-2.7 python-dragonfly

我在Windows 7 x64上使用Anaconda 64位。

我用“pip install dragonfly”成功安装了蜻蜓。

但是当我试图在IPython中导入dragonfly时,我得到了异常:

In [1]: import dragonfly
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-53bee201c97c> in <module>()
----> 1 import dragonfly

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
__init__.py in <module>()
     31 from .grammar.rule_base          import Rule
     32 from .grammar.rule_compound      import CompoundRule
---> 33 from .grammar.rule_mapping       import MappingRule
     34 from .grammar.elements  import (ElementBase, Sequence, Alternative,
     35                                 Optional, Repetition, Literal,

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
grammar\rule_mapping.py in <module>()
     79 from .rule_base         import Rule
     80 from .elements          import ElementBase, Compound, Alternative
---> 81 from ..actions.actions  import ActionBase
     82
     83

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\actions.py in <module>()
     30 from .action_base         import (ActionBase, DynStrActionBase,
     31                                   Repeat, ActionError)
---> 32 from .action_key          import Key
     33 from .action_text         import Text
     34 from .action_mouse        import Mouse

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\action_key.py in <module>()
    152
    153 from .action_base  import DynStrActionBase, ActionError
--> 154 from .typeables    import typeables
    155 from .keyboard     import Keyboard
    156

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\typeables.py in <module>()
    106     "f24":          Typeable(code=win32con.VK_F24,       name="f24"),
    107
--> 108     "alpha":        keyboard.get_typeable(char='a'),
    109     "a":            keyboard.get_typeable(char='a'),
    110     "bravo":        keyboard.get_typeable(char='b'),

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\keyboard.pyc in get_typeable(cls, char)
    139     @classmethod
    140     def get_typeable(cls, char):
--> 141         code, modifiers = cls.get_keycode_and_modifiers(char)
    142         return Typeable(code, modifiers)
    143

C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\keyboard.pyc in get_keycode_and_modifiers(cls, char)
    127             code = windll.user32.VkKeyScanW(c_wchar(char))
    128         if code == -1:
--> 129             raise ValueError("Unknown char: %r" % char)
    130
    131         # Construct a list of the virtual key code and modifiers.

ValueError: Unknown char: 'a'

问题的根源是什么?

0 个答案:

没有答案