Failure to save image offline due to dataframe size - FileNotFoundError: [WinError 206] The filename or extension is too long

If you create a dataframe of random numbers with say 1000 lines.

df = pd.DataFrame(np.random.randint(0,1000,size=(1000, 9)), columns=list(‘ABCDEFGHI’))

and you then want to save a scatter graph like this:

import plotly.express as px
fig1 = px.scatter(df, x=“A”, y=“B”, size=“D”, color=“E”,
hover_name=“F”, )

fig1.update_layout(title=‘test’,width=1200,height=500)
fig1.show()

and you then want to save that image
call([‘orca’, ‘graph’, json.dumps(fig1, cls=plotly.utils.PlotlyJSONEncoder), ‘-o’, ‘graph_name’,’-d’,‘images’,’-f’,‘svg’])

you get this error message below. if i reduce the size of the dataframe to 800 lines then it works.
any idea how to remove this size cap ?


FileNotFoundError Traceback (most recent call last)
in
----> 1 call([‘orca’, ‘graph’, json.dumps(fig1, cls=plotly.utils.PlotlyJSONEncoder), ‘-o’, ‘graph_name’,’-d’,‘images’,’-f’,‘svg’])

C:\ProgramData\Anaconda3\lib\subprocess.py in call(timeout, *popenargs, **kwargs)
321 retcode = call([“ls”, “-l”])
322 “”"
–> 323 with Popen(*popenargs, **kwargs) as p:
324 try:
325 return p.wait(timeout=timeout)

C:\ProgramData\Anaconda3\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
773 c2pread, c2pwrite,
774 errread, errwrite,
–> 775 restore_signals, start_new_session)
776 except:
777 # Cleanup if the child failed starting.

C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1176 env,
1177 os.fspath(cwd) if cwd is not None else None,
-> 1178 startupinfo)
1179 finally:
1180 # Child is launched. Close the parent’s copy of those pipe

FileNotFoundError: [WinError 206] The filename or extension is too long

Hi @travis1 it seems that you’ve had this problem several times in the past. Would you mind linking here to previous relevant posts you made so that we can address the issue with all possible information? Thanks!

bonjour Emmanuelle, merci pour votre réponse.

sorry, what do you mean by linking ? to place the link to my other posts ?

well there two things I ve noticed.

to make save image functionality work is quite hard and I don’t know why. some co worker of mine had the same issue. that’s why I use the orca call instead.
here are my other post on this issue1

issue 2 :
the size of the resulting image ( or the amount of information in it) seems to cause an issue with “this file name too long” . but I can’t quite figure out where in the library this is happening.

other posts

would be amazing to know . the library is fantastic.

I would be very happy to help the Plotly project with my ( very modest ) skills.

thanks!

Julien Fron

I ve just tried again on a Mac ( the above is on windows).
I find the same issue but the limit is at 9500 lines on the random dataframe


import plotly.express as px
import pandas as pd

df = pd.DataFrame(np.random.randint(0,1000,size=(10000, 9)), columns=list(‘ABCDEFGHI’))
df.head()
fig1 = px.scatter(df, x=“A”, y=“B”, size=“D”, color=“E”,
hover_name=“F”, )

fig1.update_layout(title=‘test’,width=1200,height=500)
fig1.show()

1000 lines of dataframe gives this error on Mac ( kind of similar but wording is different)

call([‘orca’, ‘graph’, json.dumps(fig1, cls=plotly.utils.PlotlyJSONEncoder), ‘-o’, ‘graph_name’,’-d’,‘images’,’-f’,‘svg’])


OSError Traceback (most recent call last)
in
----> 1 call([‘orca’, ‘graph’, json.dumps(fig1, cls=plotly.utils.PlotlyJSONEncoder), ‘-o’, ‘graph_name’,’-d’,‘images’,’-f’,‘svg’])

//anaconda3/lib/python3.7/subprocess.py in call(timeout, *popenargs, **kwargs)
321 retcode = call([“ls”, “-l”])
322 “”"
–> 323 with Popen(*popenargs, **kwargs) as p:
324 try:
325 return p.wait(timeout=timeout)

//anaconda3/lib/python3.7/subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
773 c2pread, c2pwrite,
774 errread, errwrite,
–> 775 restore_signals, start_new_session)
776 except:
777 # Cleanup if the child failed starting.

//anaconda3/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1520 if errno_num == errno.ENOENT:
1521 err_msg += ': ’ + repr(err_filename)
-> 1522 raise child_exception_type(errno_num, err_msg, err_filename)
1523 raise child_exception_type(err_msg)
1524

OSError: [Errno 7] Argument list too long: ‘orca’

Anyone faced the same error of not being able to save a figure to the size of the image ?

thanks

Julien

Hi All,

Anyone ever had the issue to not be able to save an image because it’s deemed too large ?