Playsound module acting strange - python

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?

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.

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.

Related

Python playsound() error when i change directory

I've a problem with Playsound and i don't know why... for me it's not understandable...
The code
from playsound import playsound
playsound(r"C:\\Users\\Toto\\Desktop\\songs\\dring.mp3")
It's work i'm happy, now i copy/paste the same directory (songs\dring.mp3) away from the desk for example my usb device (or other, no matter where i put it)
On my code i change the path
from playsound import playsound
playsound(r"D:\\songs\\ding.mp3)
i've always this error
Error 259 for command:
the driver cannot recognize the specified command parameter.
It's work only my desktop, elsewhere it does not work.. can you help me?
Thank
I found the solution...
you need to uninstall playsound 1.3.0 using :
pip uninstall playsound
(press y to proceed)
Then uninstall the old and pure version of playsound by this command :
pip install playsound==1.2.2
It worked perfectly for me

Why is the playsound function not able to play my mp3 file in python

So basically I was trying to create a music playing program that would play music when you asked it to. I was just trying to get the song playing portion to actually work, so I wrote a super simple code to test it out:
import playsound
playsound('sample.mp3')
This was done in replit, and I added the mp3 file into the files section
when I hit run, it gives me TypeError: 'module' object is not callable. What can I do to fix this?
you need to install the PyObjC by writing below command.
if you are using python version 3
pip3 install PyObjC
if you are using python version 2
pip install PyObjC
After that you write below code in your terminal
from playsound import playsound
playsound("path of your audio file/testing_audio_file.mp3")
if you are facing any issue regarding path then use below pattern for (use two forward slash) Windows
playsound("D:\\path_of_your_audio_file\\testing_audio_file.mp3")
Replace
import playsound
with...
from playsound import playsound

Python Can't Find Wolframalpha Module

I'm tyring to import wolfamalpha into my code but it gives a error saying:
ModuleNotFoundError: No module named 'wolframalpha'
I tried installing it with pip install wolframalpha, but it still doesn't work.
Here is my code:
import wolframalpha
client = wolframalpha.Client('*************')
When you run your python file, are you sure that you are using the correct python interpreter that you performed the pip install wolframalpha to? It sounds like you may have multiple versions of python on your machine and there is a mismatch. If you are using VSCode, it is easy to see which interpreter is running on the bottom of the screen, which may help you debug the issue.

How to import pygame, pyperclip?

I am fairly new to python but am having issues importing certain packages within my code. I try to import pyperclip aswell as pygame. I've installed them both manually and I've tried importing them using import pygame and import pyperclip and I get
"no module named 'pyperclip'"
and the same thing for pygame. I've tried opening by putting just import pygame and saved it to run it in the interactive shell and I've also just tried typing it into the interactive shell.
I'm running linux mint 17.3 and python 2.7.6
Has anyone else had this issue?
Any help would be appreciated. Za
I had the same problem. I am also new to Python and programming. I tried about 100 things, but what worked for me was typing the following in the command shell:
pip install pyperclip
That was it. However, I was using Windows' command module, so. . . you know. But it's worth a shot!
This link might help, too (it has Linux instructions, etc): https://github.com/asweigart/pyperclip

ImportError: No module named 'Tkinter''

Looking at this link, when I install Python it says Tcl/Tk/Tkinter will also install, but when I run a game in Python, I get an import error. I have my usual import statements as well, but it's still not working. I also looked at this very similar problem, but the answer isn't working for me.
import simplegui
import random
from tkinter import *
Assuming you are using Python 3.x, programs must be run with python3 my-program.py (not python my-program.py).
I am assuming you are using python2.
Try this
from Tkinter import *
You are putting wrong name for module. This will work.
EDIT AFTER COMMENT
For python3 install this python3-tk and your code will work.

Categories

Resources