[GRASS-user] Trying to use GRASS with Jupyter note books in Windows

Vaclav Petras wenzeslaus at gmail.com
Wed Sep 27 20:22:15 PDT 2023


Hi Vishal,

The executable on Windows is not called "grass" like on Linux but "grass8"
or "grass83" (to avoid a strange Python import error). That should do the
trick. If not, try simply providing a full path yourself including the
extension (C:\...\...bat).

Best,
Vaclav

On Wed, 27 Sept 2023 at 21:20, Vishal Mehta via grass-user <
grass-user at lists.osgeo.org> wrote:

> I'm trying to follow this setup:
>
> https://github.com/ncsu-geoforall-lab/GIS714-assignments/blob/main/GRASS_GIS_Foundations/JupyterOnWindows_Tutorial.ipynb
>
> I have stand-alone GRASS GIS 8.3 installed in Windows in C:\GRASS GIS 8.3
>
> I followed the  7 setup steps (changing set path to reflect that its
> installed in C:\GRASS GIS 8.3
> Then when i run this first part:
>
> import os
> import subprocess
> import sys
>
> # Ask GRASS GIS where its Python packages are.
> sys.path.append(
>     subprocess.check_output(["grass", "--config", "python_path"],
> text=True).strip()
> )
>
> # Import GRASS packages
> import grass.script as gs
> import grass.jupyter as gj
> --
> I get the following error:
>
> ---------------------------------------------------------------------------FileNotFoundError                         Traceback (most recent call last)
> Cell In[1], line 7      3 import sys      5 # Ask GRASS GIS where its Python packages are.      6 sys.path.append(----> 7     subprocess.check_output(["grass", "--config", "python_path"], text=True).strip()      8 )     10 # Import GRASS packages     11 import grass.script as gs
>
> File C:\GRASS GIS 8.3\Python39\lib\subprocess.py:424, in check_output(timeout, *popenargs, **kwargs)    421         empty = b''    422     kwargs['input'] = empty--> 424 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,    425            **kwargs).stdout
>
> File C:\GRASS GIS 8.3\Python39\lib\subprocess.py:505, in run(input, capture_output, timeout, check, *popenargs, **kwargs)    502     kwargs['stdout'] = PIPE    503     kwargs['stderr'] = PIPE--> 505 with Popen(*popenargs, **kwargs) as process:    506     try:    507         stdout, stderr = process.communicate(input, timeout=timeout)
>
> File C:\GRASS GIS 8.3\Python39\lib\subprocess.py:951, 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)    947         if self.text_mode:    948             self.stderr = io.TextIOWrapper(self.stderr,    949                     encoding=encoding, errors=errors)--> 951     self._execute_child(args, executable, preexec_fn, close_fds,    952                         pass_fds, cwd, env,    953                         startupinfo, creationflags, shell,    954                         p2cread, p2cwrite,    955                         c2pread, c2pwrite,    956                         errread, errwrite,    957                         restore_signals,    958                         gid, gids, uid, umask,    959                         start_new_session)    960 except:    961     # Cleanup if the child failed starting.    962     for f in filter(None, (self.stdin, self.stdout, self.stderr)):
>
> File C:\GRASS GIS 8.3\Python39\lib\subprocess.py:1420, in Popen._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_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)   1418 # Start the process   1419 try:-> 1420     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,   1421                              # no special security   1422                              None, None,   1423                              int(not close_fds),   1424                              creationflags,   1425                              env,   1426                              cwd,   1427                              startupinfo)   1428 finally:   1429     # Child is launched. Close the parent's copy of those pipe   1430     # handles that only the child should have open.  You need   (...)   1433     # pipe will not close when the child process exits and the   1434     # ReadFile will hang.   1435     self._close_pipe_fds(p2cread, p2cwrite,   1436                          c2pread, c2pwrite,   1437                          errread, errwrite)
> FileNotFoundError: [WinError 2] The system cannot find the file specified
>
>
> Can someone help figure out what the issue is?
> Thanks,
> Vishal
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20230927/17254716/attachment.htm>


More information about the grass-user mailing list