Hi,
I'm new to installing packages for python and I'm stuck unable to install playsound. I've installed the latest version of Python. I've installed latest version of PIP. When I try to run:
python -m pip install playsound.py
EDIT: Ive used various other combinations of commands as per Dr Googles suggestions and get the same error regardless of what I type.
I get the following error:
Error:
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1093, in findsource
raise OSError('could not get source code')
OSError: could not get source code
[end of output]
So my guess is that it can't download/find the files to install so I've downloaded dist\playsound-1.3.0.tar from GitHub at
https://github.com/TaylorSMarks/playsound
Im sure everyone knows the .tar file contains various files but I have no idea what PIP needs to install form this archive file. Is it the whole .tar or the files within or a single file?
If someone could show me the file/folder pip uses that would be really helpful.
Thanks in advance. M
EDIT: PS IM using OS X 12.7.1
Don't put the extension.py on the package
(Nov-10-2023, 03:07 AM)tronic72 Wrote: [ -> ]When I try to run:
python -m pip install playsound.py
you should be using
python -m pip install playsound
Note there is no
.py
at the end
this should install
playsound package from pypi
Note, it is not updated for 2 years and last supported version as per package metadata is 3.9. Possibly it MAY not work on 3.12
there is option to install tha tar or from GitHub, but there will be no difference, stick to PyPI
(Nov-10-2023, 09:07 AM)buran Wrote: [ -> ] (Nov-10-2023, 03:07 AM)tronic72 Wrote: [ -> ]When I try to run:
python -m pip install playsound.py
you should be using
python -m pip install playsound
Note there is no .py
at the end
this should install playsound package from pypi
Note, it is not updated for 2 years and last supported version as per package metadata is 3.9. Possibly it MAY not work on 3.12
there is option to install tha tar or from GitHub, but there will be no difference, stick to PyPI
As per my edit Ive used various combinations including "python -m pip install playsound" and still get the same error/s as below.
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1093, in findsource
raise OSError('could not get source code')
OSError: could not get source code
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1093, in findsource
raise OSError('could not get source code')
OSError: could not get source code
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
[python]File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1093, in findsource
raise OSError('could not get source code')
OSError: could not get source code
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
UPDATE: The following actually didn't work and isn't accurate so please ignore this post. More info is provided in the post which follows it. I have kept it for continuity's sake......
For anyone who comes across this error here's what worked. I don't know why its worked but my best guess is this.....
After trying unsuccessfully to install playsound I started looking for alternatives. I discovered another module named sounddevice. I successfully installed it and then I figured I'd try the same syntax the developer suggested for installing it. There was nothing unusual about this being
python3 -m pip install sounddevice
I used this same syntax and it worked!
python3 -m pip install playsound
My guess is there was a dependancy that sounddevice installed which playsound needed but its only a guess. Hopefully this proves helpful to someone else.
Hi,
Here's an updated update of how i got it to work. (The post above isn't accurate so please ignore it).
After posting the above message about successfully installing I jumped back into Pycharm and ...... IT STILL DID'NT WORK!.
This was despite successfully installing the playsound module prior to which I'd also installed the PyObjC module in response to the error message pycharm was giving me. Pycharm kept giving me an error that i needed to install PyObjC even though I'd installed it. Then it dawned on me that I'd installed it in the terminal in OS X so this time I installed it inside Pycharm.
So what I've discovered (I think) is that modules are only available for the files they are applied to (would love some confirmation explanation on this if anyone is willing) To test this out I uninstalled both playsound and PyObjC and it's dependancies and created a new python file. I then tried to run
from playsound import playsound
which of course didn't run. I then reinstalled playsound using pycharm followed by PyObjC also using pycharm. Then ran
from playsound import playsound
playsound("doorbell.mp3")
This worked! I know all of you experienced python people will be rolling your eyes as my lack of knowledge regarding how modules work but hopefully this will help someone else trying to install modules and/or playsound.