Error on openmc.run( )

Hello, there.

I just installed the Openmc on my Mac with conda-forge,

and then I started the examples (Modeling a Pin-Cell).

When I came to the final to execute openmc.run( ), it came out an error:

FileNotFoundError: [Errno 2] No such file or directory: 'openmc’

So, I don’t know where I made a mistake.

Thank you.!

error on openmc.run|690x425

Meanwhile, when I run the following codes of example, the Jupyter keeps running and cannot get any result, I don’t know why.

!cat $OPENMC_CROSS_SECTIONS | head -n 10
print(’ …’)
!cat $OPENMC_CROSS_SECTIONS | tail -n 10

When you run the openmc.run() function, it tries to call the openmc executable. This message means it is not able to find that executable (the directory containing it is not on your PATH environment variable). If you are running from Jupyter, make sure you are using the conda environment that you installed OpenMC in.

Thanks for your kind reply, Paul.

And finally I fixed that error.

Actually, when I run Jupyter through the Terminal, it’s fine to execute openmc.run( ).

However, when I run Jupyter through Anaconda Navigator, I’ll get the above mentioned error, and I’m sure it is run on openmc-env environment.

Anyway, I can run it through the Terminal, although I don’t know why I cannot make it through Anaconda Navigator shown as the picture.

Again, thank you, Paul.

Hallo Everyone…
I tried to run openmc but the results are as shown in the picture. Can you help me

@Darilhana1 welcome to the community! What do you have your OPENMC_CROSS_SECTIONS environment variable set to? One thing to make sure is that it points to a cross_sections.xml file, not the directory containing it.

Hello everyone,
I’m having a similar problem running this example when I try to plot the image.

plot.to_ipython_image()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[9], line 3
      1 plot = openmc.Plot.from_geometry(geometry)
      2 plot.pixels = (250, 250)
----> 3 plot.to_ipython_image()

File ~/anaconda3/envs/openmc-env/lib/python3.11/site-packages/openmc/plots.py:800, in Plot.to_ipython_image(self, openmc_exec, cwd)
    797 Plots([self]).export_to_xml(cwd)
    799 # Run OpenMC in geometry plotting mode
--> 800 openmc.plot_geometry(False, openmc_exec, cwd)
    802 # Return produced image
    803 return _get_plot_image(self, cwd)

File ~/anaconda3/envs/openmc-env/lib/python3.11/site-packages/openmc/executor.py:139, in plot_geometry(output, openmc_exec, cwd)
    121 def plot_geometry(output=True, openmc_exec='openmc', cwd='.'):
    122     """Run OpenMC in plotting mode
    123 
    124     Parameters
   (...)
    137 
    138     """
--> 139     _run([openmc_exec, '-p'], output, cwd)

File ~/anaconda3/envs/openmc-env/lib/python3.11/site-packages/openmc/executor.py:90, in _run(args, output, cwd)
     88 def _run(args, output, cwd):
     89     # Launch a subprocess
---> 90     p = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,
     91                          stderr=subprocess.STDOUT, universal_newlines=True)
     93     # Capture and re-print OpenMC output in real-time
     94     lines = []

File ~/anaconda3/envs/openmc-env/lib/python3.11/subprocess.py:1022, in Popen.__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, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1018         if self.text_mode:
   1019             self.stderr = io.TextIOWrapper(self.stderr,
   1020                     encoding=encoding, errors=errors)
-> 1022     self._execute_child(args, executable, preexec_fn, close_fds,
   1023                         pass_fds, cwd, env,
   1024                         startupinfo, creationflags, shell,
   1025                         p2cread, p2cwrite,
   1026                         c2pread, c2pwrite,
   1027                         errread, errwrite,
   1028                         restore_signals,
   1029                         gid, gids, uid, umask,
   1030                         start_new_session, process_group)
   1031 except:
   1032     # Cleanup if the child failed starting.
   1033     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/openmc-env/lib/python3.11/subprocess.py:1899, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1897     if errno_num != 0:
   1898         err_msg = os.strerror(errno_num)
-> 1899     raise child_exception_type(errno_num, err_msg, err_filename)
   1900 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'openmc'

I reviewed the path variable, but it seems to be okay.

import sys
sys.path
['/home/maxi/OpenMC/Excercises',
 '/home/maxi/anaconda3/envs/openmc-env/lib/python311.zip',
 '/home/maxi/anaconda3/envs/openmc-env/lib/python3.11',
 '/home/maxi/anaconda3/envs/openmc-env/lib/python3.11/lib-dynload',
 '',
 '/home/maxi/anaconda3/envs/openmc-env/lib/python3.11/site-packages']

This is the location of the OpenMC module:

/home/maxi/anaconda3/envs/openmc-env/lib/python3.11/site-packages/openmc/__init__.py

I’m running jupyter notebook from the Terminal, and then changing to the openmc-env environment inside the notebook, so I don’t believe this is the problem. Could you help me? Thanks!