-1

I've been using the Python playsound module to play audio, and in VScode it works great, but when I play it outside of VScode in the console instead of the audio playing like usual, I get an error saying:

ModuleNotFoundError: No module named 'playsound'

I write in from playsound import playsound to import the module, and if I just try and write, import playsound, it doesn't even work in VScode, saying "'module' object is not callable".

I've uninstalled and reinstalled the new version, uninstalled and reinstalled version 1.2.2, and I'm beginning to lose hope with playsound. Has anyone out there experienced this?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
paxous
  • 119
  • 10

2 Answers2

1

At first, second part of your question:
You cannot just

import playsound

playsound(...)

because playsound is a module in this case, which is not callable (as the interpreter told you).
you need to import function playsound from the module, that is why

from playsound import playsound

playsound(...)

works.

First part of your question:
It might be possible vscode is using another version of python from one you're calling from the command line. Without more information about your environment setup I can only guess. Try to do this:

$ python -m pip install playsound

then

$ python -m playsound "path-to-your-mp3-file.mp3"

that should work without a problem.

p1r0h
  • 21
  • 1
  • I just read on another post to use just "import playsound" also when I run the commands, the first one, I get this error: "error: C:\msys64\mingw64\bin\python.exe: No module named pip" and when I run the second command I get this: "C:\msys64\mingw64\bin\python.exe: No module named playsound" I see that the file path for both of those are where I got my c/c++ compiler, and I do remember changing some settings so I can type "G++ --version" on the command line. – paxous Dec 17 '21 at 12:45
0

I found out what was causing the problem. I had to edit the environment variables that point to pip and it started to work again.

paxous
  • 119
  • 10
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 19 '21 at 16:30