Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation error: error: subprocess-exited-with-error, OSError: could not get source code #143

Open
rogit85 opened this issue May 1, 2023 · 3 comments · May be fixed by #146
Open

Installation error: error: subprocess-exited-with-error, OSError: could not get source code #143

rogit85 opened this issue May 1, 2023 · 3 comments · May be fixed by #146

Comments

@rogit85
Copy link

rogit85 commented May 1, 2023

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.

@TaylorSMarks
Copy link
Owner

TaylorSMarks commented May 1, 2023 via email

@mattmess1221
Copy link

mattmess1221 commented May 4, 2023

I found something interesting in setup.py.

here = abspath(dirname(getsource(lambda:0)))

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

@SSSayon
Copy link

SSSayon commented May 17, 2023

Have a look at #145 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants