0

I understand there are many people who are in favor of using Jupyter Notebook, powered by IPython library. I am, however, prefer to work in PyCharm and write Python script.

When I want to reduplicate codes written in Jupyter Notebook, I found sometimes they use functions from IPython. For example, this example:

    from fastai.vision.widgets import *

    cleaner = ImageClassifierCleaner(learn)
    cleaner

Here cleaner is a class that has widgets that can be displayed in Juypter Notebook. If I run the function in a Python script, then the widget will not be shown. I tried to fix it use the following codes:

    from fastai.vision.widgets import *

    cleaner = ImageClassifierCleaner(learn)
    from IPython.display import display
    display(cleaner.widget)
    plt.show()

It does not work. Any ideas? Thanks.

ps1: use print(cleaner):

<PIL.Image.Image image mode=RGBA size=227x128 at 0x7F99C4F97470>
<PIL.Image.Image image mode=RGBA size=226x128 at 0x7F99C3679898>
<fastai.vision.widgets.ImageClassifierCleaner object at 0x7f99f803ec88>
0

1 Answer 1

2

Jupyter widgets (and the display function) use JavaScript to render the output as an HTML element within the notebook page, so you can't use those in a regular Python script. If the hang-up is that you want to be able to use PyCharm, here's how you can run a Jupyter notebook within the IDE.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.