我有这个错误。 有人可以建议吗?
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type"help","copyright","credits" or"license" for more information.
>>> import winsound
Traceback (most recent call last):
File"", line 1, in
ImportError: No module named winsound
您的操作系统是什么,以及如何安装python? 此模块仅Windows。
它是cygwin上的python(在Windows上)。
下载并安装适用于Python的预构建Windows安装程序,该安装程序包含winsound模块(无论如何32位版本都可以)。
我的机器上会有2个版本的python吗? 真是一团糟。 如果有一个链接可以安装python-winsound导入包本身?
I do not have enough points to comment hence writing in ANSWER section
我的Windows笔记本电脑上有两个python版本。 3.x和2.7.x只要没有出现任何问题,
a)您在不同的文件夹中安装两个版本
b)为每个Python版本正确设置Windows PATH变量。
从我自己的经验中可以看出,更好的选择是删除未使用的python的PATH。 例如,我没有使用3.x,所以我删除了PATH。 您以后可以随时设置
适用于Windows的Python具有MSI安装程序,该安装程序内置了winsound(与我安装的方式相同)。
或者,如果您不想安装其他版本的PYTHON,则可能希望查看winsound的替代版本。
我假设您需要使用winsound才能播放音频。
在这种情况下,您可以查看播放声音文件并使用现有的python on cygwin.的其他模块。
他们之中有一些是
pydub pip install pydub
pyaudio
pip install pyaudio
pygame
pip install pygame
$ pip安装pygame Collecting pygame Could not find a version that satisfies the requirement pygame (from versions: ) No matching distribution found for pygame
$ pip安装pyaudio #include"portaudio.h" ^ compilation terminated. error: command gcc failed with exit status 1 ---------------------------------------- Command"usrbinpython -u -c"import setuptools, tokenize;__file__=tmppip-build-9Q9Selpyaudiosetup.py;exec(compile(getattr(tokenize, open, open)(__file__).read().replace(
,
), __file__, exec))" install --record tmppip-NLGiMJ-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in tmppip-build-9Q9Selpyaudio
联系:13835327580(微信同号)