Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
snraedsoeia
Advocate II
Advocate II

Can't load environment resource to notebook

With the last update came environment resources; however, if I try to load one into my notebook, it fails. I click in the meatball menu of the file on "Open in notebook" and it gives me this code:

 

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
# Load image
image = mpimg.imread(f"{notebookutils.nbResPath}/env/drake_tech_support.gif")
# Let the axes disappear
plt.axis('off')
# Plot image in the output
image_plot = plt.imshow(image)

 

This yields this error:

 

FileNotFoundError: [Errno 2] No such file or directory: '/env/drake_tech_support.gif'

 

"notebookutils.nbResPath" alone gives "/synfs/nb_resource", adding this manually into the file path doesn't change anything.

What is going on?

1 ACCEPTED SOLUTION
Hofpower
Frequent Visitor

Hi @snraedsoeia 

 

I tried to replicate your error but I was unable to. 

After creating a completely new environment with a .gif and attaching that to a new notebook I was able to load the image the exact same way as you did. 

Hofpower_0-1725002185108.png

 

Did you do anything else in the notebook before loading the .gif or did you change any other settings in your environment besides uploading the file?

 

If not I would advise you to try again and if the error still persists maybe contact MSFT support so they can check telemetry data on your session and environment.

 

BR

Martin

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @snraedsoeia,

Where are the file stored? Can you please share some more detail about these? For my test scenario, I upload a gif file to the Lakehouse files folder and environment and copy the file API path and relative path to use mpimg.imread path to read it and it works well.

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.animation as animation

# Load the GIF file
gif_path = '/lakehouse/default/Files/Picture1.gif'

# Load the GIF file from environment
#gif_path = f"{notebookutils.nbResPath}/env/Test/Picture1.gif"

img = mpimg.imread(gif_path)

fig, ax = plt.subplots()
plt.axis("off")
im = ax.imshow(img)

plt.show(im)

If you failed to load resource, have you check if the used environment is include upload the files instead of the default environment?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Hofpower
Frequent Visitor

Hi @snraedsoeia 

 

I tried to replicate your error but I was unable to. 

After creating a completely new environment with a .gif and attaching that to a new notebook I was able to load the image the exact same way as you did. 

Hofpower_0-1725002185108.png

 

Did you do anything else in the notebook before loading the .gif or did you change any other settings in your environment besides uploading the file?

 

If not I would advise you to try again and if the error still persists maybe contact MSFT support so they can check telemetry data on your session and environment.

 

BR

Martin

Yes, my environment also had the Int96RebaseModeInWrite set to CORRECTED (but I don't know how that would impact the resources). Anyway, I set up an all new workspace, environment and notebook and it worked, so whatever. Thanks!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.