I have the below directory structure:
src/
--check.py
--quantum/
----__init__.py
----ansatz.py
----hva/
------__init__.py
------single_layer_hva.py
In my check.py, I'm doing the below:
#check.py
import quantum.ansatz as a
a.get_ansatz('sample_ansatz')
In my ansatz.py, I'm doing the below:
#ansatz.py
import hva.single_layer_hva as hva
single_layer_hva = hva.SingleLayerHVA()
In my single_layer_hva, I'm have defined a class I want to use in ansatz.py:
class SingleLayerHVA
There is no issue while executing ansatz.py and the modules are getting imported properly.
But, I'm getting the below error while executing check.py:
Traceback (most recent call last):
File "/workspaces/high-fidelity-quantum-state-preparation/src/check.py", line 1, in <module>
import quantum.ansatz as a
File "/workspaces/high-fidelity-quantum-state-preparation/src/quantum/ansatz.py", line 4, in <module>
import hva.single_layer_hva as hva
ModuleNotFoundError: No module named 'hva'
I've tried following the steps mentioned in the below link, though it's not working. https://iq-inc.com/importerror-attempted-relative-import/
Can someone suggest what can be done regarding this issue?