在Python中找不到winsound

在Python中找不到winsound

本文介绍了在Python中找不到winsound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此错误.有人可以建议吗?

I have this error. Can anyone advise?


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
>>>

推荐答案

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变量.

I've two python version on my windows laptop. 3.x and 2.7.x There will not be any issue as long as ,
a) You install two version in different folders
b) Setup windows PATH variable correctly for each Python version.

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

I have seen from my own experience that better option is to remove PATH for python not in use. For example I am not using 3.x so I removed PATH for it. You can always set it up later

适用于Windows的Python 具有内置了winsound的MSI安装程序(与我安装的方式相同)

Python for windows has MSI installer that has winsound built in (same way I installed).

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

Alternately, If you don't wish to install another version of PYTHON and then you may want to look at alternative to winsound.
I am assuming you need to use winsound in order to play an audio sound.In that case you can look at other modules that play sound file and use existing python on cygwin.
Some of them are
pydub pip install pydub

pyaudio pip install pyaudio

pygame pip install pygame

这篇关于在Python中找不到winsound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:52