且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Python中找不到winsound

更新时间:2023-11-19 18:49:40

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