Installation error: error: subprocess-exited-with-error, OSError: could not get source code
Hello, I'm trying to install playsound on my mac running Python 3.9 and getting the following error. Any suggestions how to fix?
chrisrogers@356556745867867 ~ % pip install playsound
Collecting playsound
Using cached playsound-1.3.0.tar.gz (7.7 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fv/5wd8td9d4d38tqwm7ldnjm6c0000gn/T/pip-build-env-x4qmfqab/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fv/5wd8td9d4d38tqwm7ldnjm6c0000gn/T/pip-build-env-x4qmfqab/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/private/var/folders/fv/5wd8td9d4d38tqwm7ldnjm6c0000gn/T/pip-build-env-x4qmfqab/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fv/5wd8td9d4d38tqwm7ldnjm6c0000gn/T/pip-build-env-x4qmfqab/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 6, in <module>
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/inspect.py", line 1262, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/inspect.py", line 1244, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/inspect.py", line 1081, 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.
note: This error originates from a subprocess, and is likely not a problem with pip.
As playsound is nowhere in your stacktrace, I’d assume this issue has to do with either your Python installation or pip, not playsound.TaylorOn May 1, 2023, at 07:14, rogit85 @.> wrote:
Hello, I'm trying to install playsound on my mac running Python 3.9 and getting the following error. Any suggestions how to fix?
@. ~ % pip install playsound
Collecting playsound
Using cached playsound-1.3.0.tar.gz (7.7 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/Users/chrisrogers/.pyenv/versions/3.11.3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
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.
note: This error originates from a subprocess, and is likely not a problem with pip.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
I found something interesting in setup.py.
https://github.com/TaylorSMarks/playsound/blob/9cf4af20caa5ae8586f88b65659681b24f0c4e69/setup.py#L6
This doesn't work the way you think it does. getsource() will return the relevant source code of the given object. In this case, here = abspath(dirname(getsource(lambda:0))). When passed to dirname(), it returns an empty string, which when passed to abspath(), it will always return the current directory.
Unfortunately, getsource() breaks when it isn't in a file (pip runs exec when building wheels).
To demonstrate, see the following snippet. When you run via cat | python or python -c "$(cat)", it breaks completely. The error it creates looks very familiar.
from inspect import getsource
src = getsource(lambda: 0)
print(src)
$ python < script.py
$ python -c "$(cat script.py)"
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/lib/python3.10/inspect.py", line 1147, in getsource
lines, lnum = getsourcelines(object)
File "/usr/lib/python3.10/inspect.py", line 1129, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib/python3.10/inspect.py", line 958, in findsource
raise OSError('could not get source code')
OSError: could not get source code
Have a look at https://github.com/TaylorSMarks/playsound/issues/145 !