3
$\begingroup$

I have a script to produce a custom palette that works perfectly well when run in a MM notebook, but when I try to run it as a standalone Wolfram script, it produces the dreaded:

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

The script does a number of other things that may also require access to the FrontEnd, but it appears from this post that it is the attempt to create a notebook (palette) that is the root of the problem.

Have I understood the limitation correctly? And is it also correct that there is really no way around this, other than to run the script in a MMA notebook, as I can do presently?

What I don't get is this: even if it is not possible to open a new notebook to access the frontend, why is it not possible to access any necessary frontend functionality via an already open MMA notebook (i.e. to enable the script to establish a connection to the frontend via a named, currently open notebook?'

$\endgroup$
1
  • $\begingroup$ You are asking several interesting questions. To bluntly answer your (presumed) main question: you cannot expect to generate a palette without the front end that it is a part of & is constructed from. What would you expect to happen, without a front end? Would the palette be constructed from the command line? That said, I think your final question is most interesting, and is seemingly sat between having and not-having the front end to run the palette. This is, however, not exclusive to running a palette and could apply to many other things. $\endgroup$ Mar 3, 2022 at 1:41

1 Answer 1

2
$\begingroup$

You need to tell wolframscript to launch a service frontend.

In[1]:= NotebookPut[Notebook[{}]]                                                                                            

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

Out[1]= $Failed

In[2]:= NotebookPut[Notebook[{}]] // UsingFrontEnd                                                                           

Out[2]= -NotebookObject-

Some functions where it is not obvious that you need need a frontend will do this for you (e..g, Rasterize), but notebook operations are not in that category.

If UsingFrontEnd isn't enough, that we'd need to know more about your script.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.