How Can I Import Python Custom Class In Anaconda (jupyter Notebook)
I don't manage to find how import custom class in Python with the Jupyter notebook in anaconda. In my work folder I have a file 'user.ipynb' that contains a class name User. In an
Solution 1:
Python modules are either files named *.py
or directories with an __init__.py
in them. user.ipynb
is neither, it's an IPython (Jupyter) notebook, so it is not a module and you can't import it.
The easiest way to get this to work is to convert the notebook to a .py
file (this can be done using the export function) and then you'll be able to import it.
An alternative is to provide code that lets you import notebooks directly; such code is available here. Looks like a lot of bother, though. I'm not sure why they didn't just bake this in; it seems like it would be useful.
Post a Comment for "How Can I Import Python Custom Class In Anaconda (jupyter Notebook)"