【问题标题】:"TypeError: expected bytes, str found" when calling .MidiIn() from rtmidi-python从 rtmidi-python 调用 .MidiIn() 时出现“TypeError: expected bytes, str found”
【发布时间】:2016-01-16 21:08:27
【问题描述】:

我从http://www.lfd.uci.edu/~gohlke/pythonlibs/ 上提供的 .whl 中为 Python 3.4.2 安装了 rtmidi_python,导入工作正常,但只要我调用“rtmidi_python.MidiIn()”,我就会得到一个TypeError如下:

Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import rtmidi_python
>>> rtmidi_python.MidiIn()
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    rtmidi_python.MidiIn()
  File "rtmidi_python.pyx", line 72, in rtmidi_python.MidiIn.__cinit__ (rtmidi_python.cpp:1440)
TypeError: expected bytes, str found

据我了解,经过一些研究,这意味着包本身或构建的某个地方存在错误,我对此无能为力,但我可能错了。谁能确认一下?

我使用 3.4.2,因为这是当前 Blender 版本使用的 Python 版本。我想在 Blender 游戏引擎中使用 rtmidi-python。 我目前正在使用 Windows 7 32 位,并使用 .whls 安装软件包,因为我没有常规 pip 安装所需的 C++ 编译器。

为了比较,我之前为 3.5.1 安装了 rtmidi-python,也是从上面链接中提供的足够的 .whl 中安装的,并且该命令运行得非常好。

如果缺少任何必要的信息,请随时询问。非常感谢,如果答案是评论,我不会赞成。

【问题讨论】:

    标签: python-3.4 typeerror python-wheel


    【解决方案1】:

    虽然这不是一个完美的解决方案,但可以通过此处 sehqlr 描述的方式进行修复...https://github.com/superquadratic/rtmidi-python/issues/17

    ...通过像这样调用 MidiIn()

    >>> rtmidi_python.MidiIn(b'in')
    

    【讨论】:

    • 如前所述,这是 rtmidi 特有的解决方法。
    猜你喜欢
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 2021-09-12
    • 2020-11-07
    • 2019-07-18
    • 2021-04-27
    相关资源
    最近更新 更多