Huggingface spaces not updating packages from requirements.txt
I created the following Space (Authorship Obfuscation - a Hugging Face Space by hallisky; files herehallisky/authorship-obfuscation at main) using gradio. It was working well, and I decided to expand the app and tried to addfrom transformers import AutoTokenizerto myapp.py.  I also added arequirements.txtin the root folder which hastransformers==4.41.0in it.However, when I factory rebuild this app, I get the following error===== Application Startup at 2024-06-18 23:55:09 =====

Traceback (most recent call last):
  File "/home/user/app/app.py", line 1, in <module>
    from transformers import AutoTokenizer
ModuleNotFoundError: No module named 'transformers'
=== Application stopped (exit code: 1) at 2024-06-18 23:55:17.611578322 UTC ===I’m not sure why this is happening. I tried deleting and remaking the file but still have the same issue. Could anyone point me to where I might have a mistake? Thanks for the help!
2024-10-20T19:30:33Z
Hi@hallisky, did you find a solution for that issue? I’m facing the same problem. Factory rebuild doesn’t install the requirements.txt file.I installed it manually in the vscode terminal withpip install -r requirements.txtand it works. But the same issue happens again when the server goes to sleep mode and then tries to restart.
2024-10-20T20:25:14Z
Hi@Yersel, I did not find a solution myself for this issue. I ended up going back-and-forth over email with the huggingface support trying to explain my solution. After a long thread, it started working again - but they never told me what the issue was. I assume they were able to correct something manually behind the scenes.I recommend emailing them so they can try to fix it manually. Please let me know if you find out what the underlying issue is as well!
2024-10-22T10:37:20Z
Hi@hallisky, thanks for your reply. I tried to find support from HF, but as I read, this in only from Enterprise accounts. For now, the temporary solution I found is to add this code at the beginning of  theapp.py:import os
import subprocess

def install(package):
    subprocess.check_call([os.sys.executable, "-m", "pip", "install", package])

install("transformers")With that, I forced the code to check the installation of the transformer, and if it isn’t installed, it should install it before running the rest of the code. Hopefully later, we can find an official response from HF of what is the root cause of this issue.