Custom python packages at Spaces

Hello everyone! I am trying to install custom python package to private repo under Spaces via adding it’s name to requirements.txt, and pushing package code to my HF Spaces repo. This results to ERROR: Could not find a version that satisfies the requirement avocado_lite (from versions: none) (it doesn’t surprise me). This package can be installed locally by running command pip install -e ./avocado_lite. I didn’t find any HF documentation related to this question. So, what should I do, to make my own package be installed under my HF repository environment? Thanks in advance

Can you precompile the wheel and push that instead of the package files? You should be able to direct link from a requirements.txt file to a local wheel, e.g.,


Thanks for a such quick reply, Bram!
I’ve tried your solution, but it didn’t work. My file requirements.txt has the following content:


And I’ve uploaded file under [avocado_lite]( , but I am getting an ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/user/app/avocado_lite/avocado_lite-1.0.0-py3-none-any.whl'

What should I change?

Are you sure the path is correct? You have some round brackets in there that seem out of place. You can also try again with the full (absolute) path. If that does not work, I am not entirely sure how to proceed so hopefully someone else can help you.

Yes, I am sure. I created new public repo with dummy sample python package to make sure everyone understand me. Please take a look at an error, at requirements.txt and my .whl path. Is everything correct?

UPD: can you please provide an example repo where I can see, the custom package was installed correctly?

Well you can run any shell command in python using os.system(), so perhaps the easiest way might be to replicate you how you install avocado_lite locally.

You could add something like this at the top of your file:

import os

os.system('pip install -e ./avocado_lite')

## The rest of your code goes here

Thanks for reply, Abid!
The installation error disappeared. But, I can’t use it as package in localhost by just importing it in file. It say’s “no such package”.
However, I solved this issue by specifying relative path to package in places where I call functions from it. And I added package requirements to requirements.txt file under HF repository. Now everything is working.

1 Like

Hi I am hae a problem with this exact topic. I have the following requirements file

-e ./myprimlib

myprimlib is in a subfolder in the hugging face git repo
and I get the following error
“not a valid editable requirement. It should either be a path to a local project or a VCS URL”