I've got an error when trying to create sound using pygame

Solution 1:

The file doesn't have to be in the same directory as the python file, but it has to be in the working directory of the application.

The difference can be investigated by:

import os

currentWorkDir = os.getcwd()
print(currentWorkDir)

sourceFileDir = os.path.dirname(os.path.abspath(__file__))
print(sourceFileDir)

See also Import-related module attributes.

The current working directory can be changed by the application, to be the same as the python source file directory:

import os

sourceFileDir = os.path.dirname(os.path.abspath(__file__))
os.chdir(sourceFileDir)