Python sound modules not working (Circular Import) - python

After installation of playsound and simpleaudio modules to try simple commands in order to play some audio files I always get the following message.
playsound: ImportError: cannot import name 'playsound' from partially initialized module 'playsound' (most likely due to a circular import) (/Users/joaosoares/Documents/PySound/playsound.py)
simpleaudio:AttributeError: partially initialized module 'simpleaudio' has no attribute 'WaveObject' (most likely due to a circular import)
I am currently using python 3.8.1, I've tried to create a new environment using pipenv and the problem persists. I got it to work the very first time I installed playsound. The problem might came after I had to install AppKit.NSSound as needed to run simplesound. My problem may be obvious and I apologise in advance if my issue isn't clarified I started to use python very recently.
I am following this tutorial

The only way i can reproduce your error is if i create a file called playsound.py
from playsound import playsound
playsound('myfile.wav')
ERROR
Traceback (most recent call last):
File "C:/Users/Chris/PycharmProjects/stackoverflow/stackoverflow.py", line 1, in <module>
from playsound import playsound
File "C:\Users\Chris\PycharmProjects\stackoverflow\playsound.py", line 1, in <module>
from playsound import playsound
ImportError: cannot import name 'playsound' from partially initialized module 'playsound' (most likely due to a circular import) (C:\Users\Chris\PycharmProjects\stackoverflow\playsound.py)
In your question your error specifically says your file is called playsound.py
/Users/joaosoares/Documents/PySound/playsound.py
rename this to something else otherwise it will try to import its self

There is Error in playsound Module So I has solved it for beginners
Hope so it's useful for you
Write This Command in Terminal that is provided in the image
https://i.stack.imgur.com/j6zcN.png
And Then Again Run the Python File and the Error is Solved
Now you can play sound using playsound module
https://i.stack.imgur.com/VQiNN.png
Note : Use double \ in path if you are a windows user else use \ in Mac and also enter Correct Path of song

just uninstall the current version by typing:
pip uninstall playsound
then install the older version by typing:
pip install playsound==1.2.2

just remove that playsound (use another name) and you are done

Related

Python3 Modules not loading on other computers

I have been coding an python application in PyCharm and I have had an issue when trying to run to program on other devices. When cloning the repo on my laptop I keep getting this error:
Traceback (most recent call last):
File "/home/matthew/PycharmProjects/HealthTrackerForRachel/Main.py", line 4, in <module>
from PyQt5 import QtWidgets
ModuleNotFoundError: No module named 'PyQt5'
I have done pip install PyQt5 on my current computer so it should have the module. I am also using venv so could this be causing an issue?
I think the problem has to do with installing PyQts5. here the question was answered already ImportError: No module named PytQt5.

Why does import pygame_textinput doesn't work?

I have tried using import pygame_textinput to call the pygame_textinput module. It doesn't work though. I got it from here.
Which was provided by another Stack Overflow page to get information about the pygame_textinput module as such:
How to create a text input box with pygame?
Just in case, I have tried getting it from the net as it is stated to be a third-party module but to no avail. I wrote the code in python shell as such:
import pygame_textinput
And got error message as such:
Traceback (most recent call last):
File "<pyshell#15>", line 1, in module
import pygame_textinput
ImportError: No module named pygame_textinput
Help? (PS. The word module in the error message second line is actually covered in < >. I deleted it as couldn't show.
Did you install it ? https://pypi.org/project/textinput/
pip install pygame_textinput
guide how to install pip: https://pip.pypa.io/en/stable/installing/

Python third party Module global import

i'm currently into learning a bit of python and i want to import the paperclip third party module into my python file.
Yes, i already installed the pyperclip module with
pip install pyperclip.
if i create a file on my desktop, i get an error which says
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyperclip
ImportError: No module named pyperclip
However if i put the test.py in my python folder, it runs.
The question now is, is there a way to make all my installed modules available on a global scope ? I just want to have my file e.g. on my Desktop and run it without having import issues.
Thank you.
Greetings
Edit: I'm working on a Mac, maybe this leads to the problem
Found the problem.
The pip installautomatically used pip3.5 install
whereas python test.pydidn't use python3.5 test.py
Thank you #Bakurìu
Is there a way i can define python3.5as python?
You can do this :
pip3.5 install paperclip
pyperclip is install but not paperclip

pyperclip has no attribute copy

When i run this code
import pyperclip
pyperclip.copy('German')
pyperclip.paste()
I get the error
Traceback (most recent call last):
File "C:/Windows/System32/pyperclip.py", line 1, in <module>
import pyperclip
File "C:/Windows/System32\pyperclip.py", line 2, in <module>
pyperclip.copy('German')
AttributeError: module 'pyperclip' has no attribute 'copy'
I have installed pyperclip using pip
I have tried reinstalling Pyperclip but it does nothing.
You called your module pyperclip by naming your file pyperclip.py. Therefore, your import pyperclip is actually a recursive import (importing your own module) and will not work.
To avoid this, just don't name your module the same as a library you use.
instead of pyperclip I have decided to use os:
os.system("echo '%s' | pbcopy" % STRING_NAME_HERE
I recommend start reading #nneonneo answer first and if the below solutions did not fix the problem, try this one:
In the same directory I noticed that I have paperclip.py file. I just renamed it and it stopped showing circular import error
Firstly, Have you install pyper clip module or not. if you have not install pyperclip module then it will not work

python help('modules') returns ImportError

Recently, (I have no idea when), I installed this package called pymol. Today when I was trying to copy a list of all my install modules, I encountered this error.
~/Projects$ python -c "help('modules')"
Please wait a moment while I gather a list of all available modules...
Error: unable to initalize the pymol.cmd module
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pymol/cmd.py", line 117, in <module>
from chempy import io
ImportError: cannot import name io
I've tried
sudo pip uninstall pymol
This definitely worked... but it also definitely did not work. It removed the .egg, and pip list tells me it's not installed, but the tool is still there. I open a python prompt and import it with no problem. Now my question is, if I just delete the package, is there anything that could go wrong, (WCS I'm thinking kafkaesque broken dependency fixing for the rest of my natural life.) and is there a standardized, best practice to remove this, or any other package manually.

Categories

Resources