【问题标题】:winsound not found in Python在 Python 中找不到 winsound
【发布时间】:2016-05-08 15:03:23
【问题描述】:

我有这个错误。谁能给点建议?

Python 2.7.10(默认,2015 年 6 月 1 日,18:05:38) [GCC 4.9.2] 在 cygwin 上 输入“帮助”、“版权”、“信用”或“许可”以获取更多信息。 >>> 导入winsound 回溯(最近一次通话最后): 文件“”,第 1 行,在 ImportError:没有名为 winsound 的模块 >>>

【问题讨论】:

  • 你的操作系统是什么,你是如何安装python的?此模块仅适用于 Windows。
  • 这是cygwin上的python(在windows上)。
  • 下载并安装用于 Python 的预构建 Windows 安装程序,它包括 winsound 模块(无论如何,32 位版本都有)。
  • 那么我的机器上会有 2 个版本的 python 吗?这将是一团糟。如果有安装python-winsound导入包本身的链接可以吗?
  • 你使用的是Linux系统吗?

标签: python windows audio cygwin


【解决方案1】:

我的 Windows 笔记本电脑上安装了两个 python 版本。 3.x 和 2.7.x 不会有任何问题,只要:

  1. 您将两个版本安装在不同的文件夹中
  2. 为每个 Python 版本正确设置 windows PATH 变量。

根据我自己的经验,更好的选择是删除未使用的 python 的 PATH。例如,我没有使用 3.x,所以我删除了 PATH 。以后可以随时设置

Python for windows 具有内置 winsound 的 MSI 安装程序(与我的安装方式相同)。

或者,如果您不想安装其他版本的 PYTHON,那么您可能希望查看 winsound 的替代方案。
我假设您需要使用 winsound 才能播放音频声音。 在这种情况下,您可以查看其他播放声音文件的模块并使用现有的python on cygwin.
其中一些是
pydubpip install pydub

pyaudio pip install pyaudio

pygame pip install pygame

【讨论】:

  • $ pip install pygame Collecting pygame Could not find a version that satisfies the requirement pygame (from versions: ) No matching distribution found for pygame
  • $pip install pyaudio #include "portaudio.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9Q9Sel/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NLGiMJ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9Q9Sel/pyaudio/
猜你喜欢
  • 2022-01-25
  • 1970-01-01
  • 2014-05-29
  • 1970-01-01
  • 2018-07-01
  • 2019-01-02
  • 2011-07-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多