Hi,
I've just installed OSGEO4W64
Grass 7.8.2 works (alone), as does Grass functionality through QGIS 3.10.2 (with Grass 7.8.2).
I am now trying to put together a python 3.7 script using PyCharm 2019.3.3 Community edition.
I start PyCharm using the cmd script below.
My python script fails (in the Pycharm IDE) on import grass.script as gscript.
I have set GISBASE, GRASSBIN and PATH in the windows env setup.
Please can someone point me in the correct direction to be able to write python scripts using grass modules, in pycharm.
Thanks and regards,
Zoltan.
My pycharm startup script is: @echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass78\etc\env.bat @echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass78\lib
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\grass\grass78\etc\python\grass
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
SET PYTHONPATH=%PYTHONHOME%;%PYTHONHOME%\Scripts
PATH %PYTHONPATH%;%PATH%
set PATH=C:\Program Files\Git\bin;%PATH%
start "PyCharm aware of Quantum GIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\bin\pycharm64.exe"
set
PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\grass\grass78\etc\python\grass
The path needs to be just to …\etc\python, grass is already the package name (you can examine the directory to see if there is init.py file.
There are different approaches to this. Modification of what you are doing is here, trying to get the path from GRASS GIS executable (here just grass):
On Mon, Feb 10, 2020 at 2:50 PM Vaclav Petras <wenzeslaus@gmail.com> wrote:
Hi Zoltan,
On Sun, Feb 9, 2020 at 8:15 AM Zoltan Szecsei <zoltans@geograph.co.za> wrote:
set
PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\grass\grass78\etc\python\grass
The path needs to be just to ...\etc\python, grass is already the package name (you can examine the directory to see if there is __init__.py file.
There are different approaches to this. Modification of what you are doing is here, trying to get the path from GRASS GIS executable (here just `grass`):