簡體   English   中英

ModuleNotFoundError:沒有名為“草”的模塊 | 地理信息系統 | 蟒蛇3 | CENTOS 7

[英]ModuleNotFoundError: No module named 'grass' | GRASS GIS | PYTHON3 | CENTOS 7

我想在 amazon-linux 機器上運行 Grass78,使用 centOS,沒有 GUI。 非常困難,我能夠安裝 GRASS78(來自https://grass.osgeo.org/download/的最新穩定版本)。

當我運行以下命令時(在將GRASS_GUI env var 設置為text之后)

(.venv) [ec2-user@ip-10-0-3-14 volume_calc]$ grass78
Starting GRASS GIS...
ERROR: Path '/home/ec2-user/volume_calc/<UNKNOWN>/<UNKNOWN>' doesn't exist
Exiting...

我認為,有了這個,我可以確定安裝了草。

但請告訴我是否有適當的文檔來安裝它。 我試過這個( https://copr.fedorainfracloud.org/coprs/neteler/grass78/ )但它失敗了,因為那里缺少一個用於centos7的epel文件。

現在,我想運行一個 python 腳本,它會給我傳遞給腳本的多邊形對象的體積。 我不確定,以哪種方式運行 GRASS。 我是否必須明確啟動 Grass 或使用它(https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library )?

另外,我不確定在啟動 GRASS 之前需要設置哪些環境變量。 我已經設置GRASSBINGISBASEGISDBASE 但我不確定MAPSETLOCATION環境變量的值。

而且,每次我使用

from grass.script import gcore

我收到沒有找到名為 Grass 的模塊的錯誤。

由於我使用的是 centOS,所以我無法執行sudo apt install grass-core類的操作。 當我這樣做時, sudo yum install grass Grass ,它出於某種原因安裝了版本 Grass6.4.4。

我還嘗試使用grass_session ( pip install grass_session ) 在GRASS 會話中運行代碼,但是沒有運氣,二進制文件(即/usr/local/bin/grass78)本身說沒有名為grass 的模塊。

我在終端上運行以下命令。

grass78 -c EPSG:4326 location --exec python3 /home/ec2-user/volume_calc/grass_calc_vol.py area_file=/home/ec2-user/volume_calc/media/tour_id/temp-testing/area_file.geojson  points_file=/home/ec2-user/volume_calc/media/tour_id/temp-testing/points_file.geojson  dsm_file=/home/ec2-user/volume_calc/media/tour_id/files/dsm-volume.tif
Starting GRASS GIS...
Creating new GRASS GIS location <location>...
Traceback (most recent call last):
  File "/usr/local/bin/grass78", line 2349, in <module>
    main()
  File "/usr/local/bin/grass78", line 2249, in main
    geofile=params.geofile, create_new=True)
  File "/usr/local/bin/grass78", line 1003, in set_mapset
    create_location(gisdbase, location_name, geofile)
  File "/usr/local/bin/grass78", line 794, in create_location
    from grass.script import core as gcore  # pylint: disable=E0611
ModuleNotFoundError: No module named 'grass'

如果您需要有關 Grass_calc_vol 文件的更多信息,請告訴我。

這可能很晚了,但我剛剛發現這個問題有同樣的問題。 我發現導入的順序有所不同: grass_session必須在其他草模塊之前導入,例如:

from grass_session import Session
import grass.script as gscript
from grass.pygrass.vector import VectorTopo

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM