On GitHub actions, "pip install playsound" failed with the "OSError: could not get source code" error
Asked Answered
R

3

6

I am running Pylint on the GitHub actions. Before it runs, it installs the module playsound during the dependencies installation.

The checks all failed with Python 3.8, 3.9, and 3.10.

It seems to fail with the following error:

OSError: could not get source code

Do you have any idea to fix it?

Collecting playsound==1.3.0 (from -r requirements.txt (line 1))
  Downloading playsound-1.3.0.tar.gz (7.7 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 6, in <module>
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 1139, in getsource
          lines, lnum = getsourcelines(object)
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 1121, in getsourcelines
          lines, lnum = findsource(object)
        File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 958, in findsource
Error:           raise OSError('could not get source code')
      OSError: could not get source code
      [end of output]

What I have tried so far is:

>>> pip uninstall wheel
>>> pip install playsound
>>> pip install wheel

This thread kindly suggested this procedure, but did not work for me.


@Azeem, Thanks for your suggestions! Let me summarize the details of what I have tried so far.

  • requirements.txt
playsound==1.3.0
  • .github/workflows/pylint.yml
name: Pylint

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10"]
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
        pip install pylint
    - name: Analysing the code with pylint
      run: |
        pylint $(git ls-files '*.py')

The installation with this requirements.txt file works fine in the local environment with Python 3.10.9.

$ pip3 install -r requirements.txt
Collecting playsound==1.3.0
  Downloading playsound-1.3.0.tar.gz (7.7 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: playsound
  Building wheel for playsound (setup.py) ... done
  Created wheel for playsound: filename=playsound-1.3.0-py3-none-any.whl size=7022 sha256=6d5b836046d0875702d97edb41c78ad993e0057fc50dab24783790b6bf83b36d
  Stored in directory: /Users/username/Library/Caches/pip/wheels/24/f9/b3/2ed63b5d2a91bbf7da060acdc294c1335db338ec81f0c76e1b
Successfully built playsound
Installing collected packages: playsound
Successfully installed playsound-1.3.0
Restore answered 30/4, 2023 at 15:28 Comment(2)
Does the same procedure work locally? If yes, include Python version and the relevant details in your question. Also, add your GHA workflow in your question.Raffinose
@Azeem, Thanks for your suggestions! I have updated my post with the info you mentioned.Restore
R
5

According to this thread, installing/upgrading wheel worked.

I tried the same with your use case and it worked fine.

Here's the sample workflow that I used:

name: python_playsound_test

on: workflow_dispatch

jobs:
  ci:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10"]

    steps:
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        mkdir test && cd test
        echo 'playsound==1.3.0' > requirements.txt

        python --version
        pip --version

        python -m pip install --upgrade pip
        pip install --upgrade wheel
        pip install -r requirements.txt

Here's the screenshot where it passed for the matrix:

screenshot

Raffinose answered 1/5, 2023 at 6:41 Comment(3)
Thank you so much!! Adding the pip install --upgrade wheel before pip install -r requirements.txt did work!!!! Thanks a lot for your help!!!Restore
@noriko: Glad to hear that. :) In addition, you might want to start using venv to contain your code. See docs.python.org/3/library/venv.html for more details.Raffinose
I think I see your point! Currently, I am mixing all dependencies in my local, and that might have made it hard to find out the issue. I agree that it's good practice to keep dependencies separate by projects. Thanks a lot for your suggestions:)! I will learn more about venv!Restore
K
15

In my case upgrading only wheels didn't help, but pip install --upgrade setuptools wheel did :)

Kynan answered 23/1, 2024 at 22:52 Comment(0)
R
5

According to this thread, installing/upgrading wheel worked.

I tried the same with your use case and it worked fine.

Here's the sample workflow that I used:

name: python_playsound_test

on: workflow_dispatch

jobs:
  ci:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10"]

    steps:
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        mkdir test && cd test
        echo 'playsound==1.3.0' > requirements.txt

        python --version
        pip --version

        python -m pip install --upgrade pip
        pip install --upgrade wheel
        pip install -r requirements.txt

Here's the screenshot where it passed for the matrix:

screenshot

Raffinose answered 1/5, 2023 at 6:41 Comment(3)
Thank you so much!! Adding the pip install --upgrade wheel before pip install -r requirements.txt did work!!!! Thanks a lot for your help!!!Restore
@noriko: Glad to hear that. :) In addition, you might want to start using venv to contain your code. See docs.python.org/3/library/venv.html for more details.Raffinose
I think I see your point! Currently, I am mixing all dependencies in my local, and that might have made it hard to find out the issue. I agree that it's good practice to keep dependencies separate by projects. Thanks a lot for your suggestions:)! I will learn more about venv!Restore
K
0

Install pip install playsound3 instead of pip install playsound

Krefeld answered 30/9, 2024 at 7:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.