FileNotFound Error Inconsistency

I’ve been working on a simple app to reformat user uploaded images. The app was working perfectly around mid-day on Friday, but without me changing anything, it now tosses an error. I have tried restoring prior working iterations of the app, and they now toss the same error as well. I had tested these prior versions from a variety of browsers and devices, all with perfect functionality. But now, none of them work on any device. For whatever reason, this code used to work, and now does not.

This is the error that I am getting:

FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/tmp']

It occurs when trying to call to a server function, and the error occurs at the following line:

with anvil.media.TempFile(file) as filename:
        img=cv.imread(filename)

Now, I am working off of the free account, so both client and server are running basic Python3, and have been since I began building this app. I’ve found a post with a very similar issue on the forum already (link below), but I want to stress that I was able to write files before using basic Python3. The app was working perfectly. I understand it probably shouldn’t have been working, given the info in the related forum post, but it was!

Related Forum Post: Cannot access server module '/tmp' directory - #6 by drummer687

Any help is appreciated. If there is a better way to create/send files between client and server, that would work too! Or if I could create an anvil media file directly from an array of pixel values, that would work I think! I am very new to this, so any constructive criticism is welcome and appreciated.

Clone Link:
https://anvil.works/build#clone:QGS7JLOU6MAQP4AP=PC6REWCCXRBAUWXEX5LKPPOU

Hi @jack_baumgartel,

It’s really frustrating when something that seemed to be working suddenly isn’t, but as the principal author of the sandbox environments used by the Basic Python 2 and 3 runtimes, I can personally confirm that you have never been able to write to files in either of those environments - so if the code you quote ever succeeded in the past, it was not in a Basic Python runtime.

If your app was previously working, my two best guesses are that either:

  • That code was previously running in a different environment (eg a Full Python trial, or the Uplink, or possibly some weird edge case with very old apps)

  • That code was previously not executing - you just didn’t hit the code path, so it didn’t have a chance to fail, but now something has changed and that code is trying to execute.

Yes, @meredydd you were spot on! I was still running via the Uplink, so when I turned off my computer for the weekend it stopped working. Thank you for the insight and help!