USDA-ARS-NWRC / topocalc

Sky view and terrain configuration factors
Other
13 stars 8 forks source link

ImportError: cannot import name 'topo_core' #12

Open langford77840 opened 2 years ago

langford77840 commented 2 years ago

Description

slope, aspect calculation worked well. But, I can't calculate svf, tvf with this error message.

ImportError Traceback (most recent call last) /tmp/ipykernel_5913/83726565.py in ----> 1 from topocalc.viewf import viewf 2 3 # # Load the DEM into a numpy array 4 # dem_pre_path = 'dsm_ups_crs.tif' 5 # dem = rxr.open_rasterio(dem_pre_path)

~/workspace/topocalc/topocalc/viewf.py in 2 3 from topocalc.gradient import gradient_d8 ----> 4 from topocalc.horizon import horizon 5 6

~/workspace/topocalc/topocalc/horizon.py in 1 import numpy as np 2 ----> 3 from topocalc.core_c import topo_core 4 from topocalc.skew import adjust_spacing, skew 5

~/workspace/topocalc/topocalc/core_c/init.py in 1 # -- coding: utf-8 -- ----> 2 from . import topo_core # noqa

ImportError: cannot import name 'topo_core' from partially initialized module 'topocalc.core_c' (most likely due to a circular import) (/home/workspace/topocalc/topocalc/core_c/init.py)

What I Did

I changed in' init.py' file from " from . import topo_core" to "from . import * ". But another error message comes up as follows:

ImportError Traceback (most recent call last) /tmp/ipykernel_15634/83726565.py in ----> 1 from topocalc.viewf import viewf 2 3 # # Load the DEM into a numpy array 4 # dem_pre_path = 'dsm_ups_crs.tif' 5 # dem = rxr.open_rasterio(dem_pre_path)

~/workspace/topocalc/topocalc/viewf.py in 2 3 from topocalc.gradient import gradient_d8 ----> 4 from topocalc.horizon import horizon 5 6

~/workspace/topocalc/topocalc/horizon.py in 1 import numpy as np 2 ----> 3 from topocalc.core_c import topo_core 4 from topocalc.skew import adjust_spacing, skew 5

ImportError: cannot import name 'topo_core' from 'topocalc.core_c' (/home/workspace/topocalc/topocalc/core_c/init.py)

I guess still I can't import topo_core properly.

Would you help me or give any suggestions to solve this issue???

Thanks in advance for your help.

scotthavens commented 2 years ago

Sorry for the slow reply.

Are you installing this from source or from PyPi? It seems like you have the source code so you might need to have cython installed and then install topocalc with python3 setup.py install or python3 -m pip install .

simonmarti1992 commented 2 years ago

Helllo I have the same issue as @langford77840 , I cannot install the package properly on windows

Hedrick-ARS commented 2 years ago

Hi @simonmarti1992 - did you also try what @scotthavens suggested? On Windows you would need to be installing within a Docker environment running Ubuntu 18.04.