watsonx.ai

  • 1.  how do you add python libraries to notebook runtime?

    Posted Fri October 30, 2020 07:48 AM
    ---------------------------------------------------------------------------
    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-2-5178c9f2d38f> in <module>
    ----> 1 from keras.preprocessing.image import ImageDataGenerator
    
    ModuleNotFoundError: No module named 'keras'


    ------------------------------
    Michael Mitchell
    ------------------------------

    #WatsonStudio


  • 2.  RE: how do you add python libraries to notebook runtime?

    Posted Mon November 02, 2020 01:50 AM
    Usually I ask the the support/operator of the runtime environment for help.

    ------------------------------
    Matthias Jungbauer
    ------------------------------



  • 3.  RE: how do you add python libraries to notebook runtime?

    Posted Mon November 02, 2020 05:41 AM

    On public IBMCloud, only tensorflow is in the image by default. So you can:

    import tensorflow as tf
    print(tf.__version__)

    import tensorflow.keras as keras
    print(keras.__version__)

    from tensorflow.keras.preprocessing.image import ImageDataGenerator



    ------------------------------
    Philippe Gregoire
    IBM France - TSP & ISV Technical Enablement - Data&AI, IoT Europe
    NICE, France
    ------------------------------



  • 4.  RE: how do you add python libraries to notebook runtime?

    Posted Mon November 02, 2020 05:47 AM

    otherwise, you'll have to pip install it:

    try:
        import keras
    except ModuleNotFoundError:
        !pip install keras==2.2.4
        import keras
    print(keras.__version__)

    But you have to make sure you use a version of keras compatible with  the current tensorflow. Otherwise, pip install tf as well.



    ------------------------------
    Philippe Gregoire
    IBM France - TSP & ISV Technical Enablement - Data&AI, IoT Europe
    NICE, France
    ------------------------------



  • 5.  RE: how do you add python libraries to notebook runtime?

    Posted Wed November 04, 2020 11:49 AM
    Thanks!

    ------------------------------
    Michael Mitchell
    ------------------------------