How to install streamlit profiler?

hello there, I want to optimize my streamlit app by detecting and correcting slow parts of my code. I found a component named streamlit profiler, but I did not install it successfully, it make a bug:

error: subprocess-exited-with-error

  × Building wheel for pyinstrument (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [137 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\frame.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\middleware.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\processors.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\profiler.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\session.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\stack_sampler.py -> build\lib.win-amd64-cpython-312\pyinstrument        
      copying pyinstrument\typing.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\util.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\__init__.py -> build\lib.win-amd64-cpython-312\pyinstrument
      copying pyinstrument\__main__.py -> build\lib.win-amd64-cpython-312\pyinstrument
      creating build\lib.win-amd64-cpython-312\pyinstrument\magic
      copying pyinstrument\magic\magic.py -> build\lib.win-amd64-cpython-312\pyinstrument\magic    
      copying pyinstrument\magic\_utils.py -> build\lib.win-amd64-cpython-312\pyinstrument\magic   
      copying pyinstrument\magic\__init__.py -> build\lib.win-amd64-cpython-312\pyinstrument\magic 
      creating build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\base.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\console.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\html.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\jsonrenderer.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\speedscope.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      copying pyinstrument\renderers\__init__.py -> build\lib.win-amd64-cpython-312\pyinstrument\renderers
      creating build\lib.win-amd64-cpython-312\pyinstrument\vendor
      copying pyinstrument\vendor\appdirs.py -> build\lib.win-amd64-cpython-312\pyinstrument\vendor      copying pyinstrument\vendor\decorator.py -> build\lib.win-amd64-cpython-312\pyinstrument\vendor
      copying pyinstrument\vendor\__init__.py -> build\lib.win-amd64-cpython-312\pyinstrument\vendor
      running egg_info
      writing pyinstrument.egg-info\PKG-INFO
      writing dependency_links to pyinstrument.egg-info\dependency_links.txt
      writing entry points to pyinstrument.egg-info\entry_points.txt
      writing requirements to pyinstrument.egg-info\requires.txt
      writing top-level names to pyinstrument.egg-info\top_level.txt
      reading manifest file 'pyinstrument.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching '*.ts' under directory 'html_renderer'
      warning: no files found matching '*.css' under directory 'html_renderer'
      no previously-included directories found matching 'html_renderer\node_modules'
      no previously-included directories found matching 'html_renderer\dist'
      adding license file 'LICENSE'
      writing manifest file 'pyinstrument.egg-info\SOURCES.txt'
      C:\Users\secpre\AppData\Local\Temp\pip-build-env-uc4kpybd\overlay\Lib\site-packages\setuptools\command\build_py.py:218: _Warning: Package 'pyinstrument.low_level' is absent from the `packages` configuration.
      !!
     
              ********************************************************************************     
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'pyinstrument.low_level' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.
     
              This leads to an ambiguous overall configuration. If you want to distribute this     
              package, please make sure that 'pyinstrument.low_level' is explicitly added
              to the `packages` configuration field.
     
              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).
     
              You can read more about "package discovery" on setuptools documentation page:        
     
              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html
     
              If you don't want 'pyinstrument.low_level' to be distributed and are
              already explicitly excluding 'pyinstrument.low_level' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in        
              combination with a more fine grained `package-data` configuration.
     
              You can read more about "package data files" on setuptools documentation page:       
     
              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html
     
     
              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************     
     
      !!
        check.warn(importable)
      C:\Users\secpre\AppData\Local\Temp\pip-build-env-uc4kpybd\overlay\Lib\site-packages\setuptools\command\build_py.py:218: _Warning: Package 'pyinstrument.renderers.html_resources' is absent from the `packages` configuration.
      !!
     
              ********************************************************************************     
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'pyinstrument.renderers.html_resources' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.
     
              This leads to an ambiguous overall configuration. If you want to distribute this     
              package, please make sure that 'pyinstrument.renderers.html_resources' is explicitly 
added
              to the `packages` configuration field.
     
              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).
     
              You can read more about "package discovery" on setuptools documentation page:        
     
              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html
     
              If you don't want 'pyinstrument.renderers.html_resources' to be distributed and are  
              already explicitly excluding 'pyinstrument.renderers.html_resources' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in        
              combination with a more fine grained `package-data` configuration.
     
              You can read more about "package data files" on setuptools documentation page:       
     
              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html
     
     
              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************     
     
      !!
        check.warn(importable)
      creating build\lib.win-amd64-cpython-312\pyinstrument\low_level
      copying pyinstrument\low_level\stat_profile.c -> build\lib.win-amd64-cpython-312\pyinstrument\low_level
      creating build\lib.win-amd64-cpython-312\pyinstrument\renderers\html_resources
      copying pyinstrument\renderers\html_resources\app.js -> build\lib.win-amd64-cpython-312\pyinstrument\renderers\html_resources
      running build_ext
      building 'pyinstrument.low_level.stat_profile' extension
      creating build\temp.win-amd64-cpython-312\Release\pyinstrument\low_level
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\secpre\anaconda3\envs\BimoChat_2904\include -IC:\Users\secpre\anaconda3\envs\BimoChat_2904\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcpyinstrument/low_level/stat_profile.c /Fobuild\temp.win-amd64-cpython-312\Release\pyinstrument/low_level/stat_profile.obj
      stat_profile.c
      pyinstrument/low_level/stat_profile.c(301): error C2037: a la izquierda de 'f_back' se especifica '_frame' struct/union sin definir
      pyinstrument/low_level/stat_profile.c(302): error C2037: a la izquierda de 'f_back' se especifica '_frame' struct/union sin definir
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyinstrument
Failed to build pyinstrument
ERROR: Could not build wheels for pyinstrument, which is required to install pyproject.toml-based projects

command: pip install streamlit-profiler.

did somebody know how fix it?

The package is quite old, you might be able to install it in python<3.11.

Alternatively you may try one of the existing forks:

it works, thanks a lot.