Hub documentation

Handling Spaces Dependencies

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Handling Spaces Dependencies

Default dependencies

The default Spaces environment comes with several pre-installed dependencies:

  • The huggingface_hub client library allows you to manage your repository and files on the Hub with Python and programmatically access the Inference API from your Space. If you choose to instantiate the model in your app with the Inference API, you can benefit from the built-in acceleration optimizations. This option also consumes less computing resources, which is always nice for the environment! 🌎

    Refer to this page for more information on how to programmatically access the Inference API.

  • requests is useful for calling third-party APIs from your app.

  • datasets allows you to fetch or display any dataset from the Hub inside your app.

  • The SDK you specified, which could be either streamlit or gradio. The version is specified in the README.md file.

  • Common Debian packages, such as ffmpeg, cmake, libsm6, and few others.

Adding your own dependencies

If you need other Python packages to run your app, add them to a requirements.txt file at the root of the repository. The Spaces runtime engine will create a custom environment on-the-fly. You can also add a pre-requirements.txt file describing dependencies that will be installed before your main dependencies. It can be useful if you need to update pip itself.

Debian dependencies are also supported. Add a packages.txt file at the root of your repository, and list all your dependencies in it. Each dependency should be on a separate line, and each line will be read and installed by apt-get install.

< > Update on GitHub