martibosch / detectree-examples

Example computational workflows to classify tree/non-tree pixels in Zurich using DetecTree
GNU General Public License v3.0
19 stars 15 forks source link

ModuleNotFoundError: No module named 'detectree_example' #9

Closed 37310N closed 2 years ago

37310N commented 2 years ago

Performing !make tiles in the baseline.ipynb executes with the following error message:

Traceback (most recent call last): File "…/detectree-example/detectree_example/make_tiles.py", line 18, in from detectree_example import settings ModuleNotFoundError: No module named 'detectree_example' make: *** [Makefile:70: data/interim/tiles/downsampled_tiles.csv] Error 1

I used these instructions to install detectree and then cloned the detectree-example repo as described on the < Code > page. The conda env is running with Python 3.10.6

The DOP gets downloaded properly and an intersecting_tiles.csv is also created, but then fails see quote. Any suggestions @martibosch ?

Cheers, Matt

37310N commented 2 years ago

Could help myself, rewriting the code in make_tiles.py, changing the CRS manually as follows:

https://github.com/martibosch/detectree-example/blob/0fbb47e6120dd1c9801094d79988687b4b731f54/detectree_example/make_tiles.py#L18

#from detectree_example import settings

https://github.com/martibosch/detectree-example/blob/0fbb47e6120dd1c9801094d79988687b4b731f54/detectree_example/make_tiles.py#L108

#crs = settings.CRS
crs="epsg:2056"

https://github.com/martibosch/detectree-example/blob/0fbb47e6120dd1c9801094d79988687b4b731f54/detectree_example/make_tiles.py#L144

#crs = settings.CRS
crs="epsg:2056"

Better practise would be, to define crs globally like e.g.

epsg = "epsg:2056"
crs = epsq
37310N commented 2 years ago

Ok, while using another jupiter notebook I found the solution: First of all one has to ensure to be in the correct folder, e.g. if you run the first command %cd twice, you'll be in the wrong folder and the module can't be found. Therefore you should expand the command using the full path to the main directory.

But the issue prompted is within the make_tiles.py file on line 18. The following code will import the settings.py, try grabbing it from the folder detectree_example, which is located in the main directory: https://github.com/martibosch/detectree-example/blob/0fbb47e6120dd1c9801094d79988687b4b731f54/detectree_example/make_tiles.py#L18 Because both files are located in the same folder, the settings.py can't be found and you have to change the code into:

#from detectree_example  # --- one could also delete this line completely ---
import settings