远程教学支持系统
 
STUDENT
 
FACULTY
 
SCHOOL
 
SUPPORT
 
PUBLIC
 
SIGNUP
DAILY QUIZ
 
     
  B U L L E T I N    B O A R D

Install TensorFlow with Python and Jupiter Lab

(Subject: Data Analytics/Authored by: Liping Liu on 4/11/2024 4:00:00 AM)/Views: 3361
Blog    News    Post   

In order to install Tensor Flow for R, we will have to install Python first. In addition, we might install Jupyter Notebook and Jupyter Lab as well in case we want to run Python code. Another option for installing Python with Jupyter is to install Anaconda, which includes Python and options to install Jupyter and other packages later. 

Install Python

  1. Go to https://www.python.org/downloads/release/python-390/ and download Python 3.9 for Windows 64-bit (later versions may not work for Tensor Flow package). 
  2. Double click to install Python (choose Custom Installation for all users. Check
    Add python.exe to PATH box.
  3. Select all optional features in the next screen if you choose customized installation 
  4. Select Install Python 3.9 for all users for customized installation and add Python to environment variables
  5. Press Install to finish installing Python

Install Jupyter Lab

  1. Run CMD as Administrator
  2. To check your Python installation, type command: python --version
  3. Type following commands to install Jupyter Notebook and Jupyter Lab: 
    pip install notebook
    pip install ipykernel
    python -m ipykernel install
    pip install jupyterlab
  4. You may also try to install packages using pip, for example, openpyxl package for managing Excel data and Pillow for pictures: 
    pip install openpyxl
    pip install Pillow
  5. To open JupyterLab, type command: jupyter lab 
  6. Try to run the following Python code to copy a picture named A11.jpg into the A1 cell of your Excel file: 
    import openpyxl
    from openpyxl.drawing.image import Image
    # Open the workbook and select the worksheet
    workbook = openpyxl.Workbook()
    worksheet = workbook.active
    # Load the image file
    img = Image('c:\\temp\\A11.jpg')
    # Add the image to the worksheet at cell A1
    worksheet.add_image(img, 'A1')
    # Save the workbook
    workbook.save('c:\\temp\\photo.xlsx')

 

Install Tensor Flow

  1. Open R
  2. Install Tensor Flow Package by command: 

    install.packages("keras")

    library(keras)

    #assume your installed python into C:\Program Files\Python39\

    reticulate::use_python("C:\\Program Files\\Python39\\python.exe")

    reticulate::py_install("tensorflow")

    reticulate::py_install("keras")

  3.   Restart R

  4.  Type commands:

    library(keras)

    install_keras()

   5. Try the installation with commands:

    model = keras_model_sequential()

 

Errors and Fixes:

  1. If you get error messages saying "multiple virtualenv exist or default vitualenv not compatible" or something like that, go to your R working directory (you can find it out by the command getwd() in R), go the directory, delete .virtualenv folder. And then perform the installation as normal. 

           Register

Blog    News    Post
 
     
 
Blog Posts    News Digest    Contact Us    About Developer    Privacy Policy

©1997-2024 ecourse.org. All rights reserved.