1 year ago
#383717
mdelas
Problems with import, __init__.py with .ipynb
I'm a beginner organizing my code properly in python and I am struggling a bit doing imports in my main .ipynb
from a .py
script.
My folder is organized as it follows:
| naive.ipynb
| requirements.txt
|
+---data
| DNA_train.txt
| pseudomona.feather
| pseudo_test.csv
| pseudo_train.csv
|
+---model
| dna_token.model
|
\---src
token_dna_converter.py
__init__.py
As I have read, to be able to import classes from a different folder, I should add a __init__.py
file to able access from a super folder. In the __init__.py
I put the following:
from .token_dna_converter import tokenDNA
Afterwards, I want to call this script in a notebook and I have tried the following:
from token_dna_converter import tokenDNA
However, the .ipynb does not detect this inner "package"... I don't know why and I am struggling to try to fix this.
Does anyone know how should I properly call this script? I would appreciate everything!
python
init
code-organization
0 Answers
Your Answer