winsound not found in Python

梦想与她 提交于 2020-01-24 13:50:07

问题


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

回答1:


I do not have enough points to comment hence writing in ANSWER section

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.

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

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

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



来源:https://stackoverflow.com/questions/35108901/winsound-not-found-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!