benfred / py-spy

Sampling profiler for Python programs
MIT License
12.53k stars 414 forks source link

Unable to install on Raspberry pi OS (buster) #488

Open titiviking opened 2 years ago

titiviking commented 2 years ago

I'm attempting to install py-spy on my raspberry, but it fails to run:

root@raspberrypi:~# py-spy record --pid 27752
py-spy: error while loading shared libraries: libunwind-ptrace.so.0: cannot open shared object file: No such file or directory

Attempting to install directly within a container also fails to install with a failure to install "wheels for maturin":

bash-5.1# pip install py-spy
Collecting py-spy
  Using cached py_spy-0.3.11.tar.gz (155 kB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [62 lines of output]
      Collecting maturin<0.12,>=0.11
        Using cached maturin-0.11.5.tar.gz (469 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 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/toml/
      Collecting toml~=0.10.0
        Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
      Building wheels for collected packages: maturin
        Building wheel for maturin (pyproject.toml): started
        Building wheel for maturin (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        × Building wheel for maturin (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [35 lines of output]
            running bdist_wheel
            running build
            running install
            Traceback (most recent call last):
              File "/tmp/tmpa81y5q8n_in_process.py", line 363, in <module>
                main()
              File "/tmp/tmpa81y5q8n_in_process.py", line 345, in main
                json_out['return_val'] = hook(**hook_input['kwargs'])
              File "/tmp/tmpa81y5q8n_in_process.py", line 261, in build_wheel
                return _build_backend().build_wheel(wheel_directory, config_settings,
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 216, in build_wheel
                return self._build_with_temp_dir(['bdist_wheel'], '.whl',
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 202, in _build_with_temp_dir
                self.run_setup()
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
                exec(compile(code, __file__, 'exec'), locals())
              File "setup.py", line 106, in <module>
                setup(
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
                return distutils.core.setup(**attrs)
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
                dist.run_commands()
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
                self.run_command(cmd)
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
                cmd_obj.run()
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 335, in run
                self.run_command('install')
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
                self.distribution.run_command(command)
              File "/tmp/pip-build-env-wdjqx0hi/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
                cmd_obj.run()
              File "setup.py", line 58, in run
                raise RuntimeError(
            RuntimeError: cargo not found in PATH. Please install rust (https://www.rust-lang.org/tools/install) and try again
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for maturin
      Failed to build maturin
      ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects
      WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
      You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies 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.
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
bash-5.1# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
curl: (22) The requested URL returned error: 404
rustup: installer for platform 'armv7-unknown-linux-musleabihf' not found, this may be unsupported
Jongy commented 2 years ago

You're missing libunwind DSOs which are not bundled with py-spy AFAIK.

Try installed this package, I think that's what you need for Debian.

Trolldemorted commented 2 years ago

could you emit a more helpful error message in that case? Why is it trying to do cargo things if it should use precompiled binaries?

Jongy commented 2 years ago

I'm not sure if py-spy is packaged as Aarch64 (or whatever raspberry pi runs).

If it is - you can try deleting the cache (pip says "using cached") and passing --prefer-binary

Trolldemorted commented 2 years ago

We that the same behaviour on x86_64, but I think it was alpine/musl which probably explains it if you don't package for musl.