I have micrograd2 under micrograd folder but this error shows when I run test.py. how to fix it ?
File “/home/zt/bilyz_website_new/code/micrograd/test/test.py”, line 2, in
It looks like Python is unable to find the micrograd2
module. Here are a few steps you can try to resolve this issue:
Check the Directory Structure: Ensure that the micrograd2
folder is correctly placed within the micrograd
directory and that it contains an __init__.py
file. This file is necessary for Python to recognize the directory as a package.
micrograd/
├── micrograd2/
│ ├── __init__.py
│ └── engine.py
└── test/
└── test.py
micrograd2
is a subdirectory of micrograd
, you might need to adjust your import statement in test.py
to reflect the correct path. Try changing: from micrograd2.engine import Value
to:
from micrograd.micrograd2.engine import Value
micrograd
directory is included in your PYTHONPATH
. You can temporarily add it by running: export PYTHONPATH=/home/zt/bilyz_website_new/code/micrograd:$PYTHONPATH
test.py
from the micrograd
directory or adjust your working directory accordingly.