Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Smart calculator in Python
Next article icon

How to run Python code on Google Colaboratory

Last Updated : 04 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Prerequisite: How to use Google Colab Google provides Jupyter Notebook like interface to run Python code on online Virtual Machines. In this article, we will see how to run simple Python code on Google Colab. Step #1: Open https://colab.research.google.com/ Step #2: Select New Python3 Notebook Step #3: Start Typing code into the code cells. Import all necessary libraries. Step #4: To add new cell, click on Insert->Code Cell Step #5: To run a particular cell, select the cell and press Ctrl + ENTER keys.

Code cells under process

Output after successful run

Installing any particular module –

We might need to install some external modules while working on some projects in Google Colab. By default not all the required modules are being pre-installed in Google Colab. So how can we install them using pip command ?

Step – 1 : Open a new blank code cell.

Step – 2 : Try to import that module and check if it is pre-installed or not.

 

Here I am trying to import the Streamlit module which doesn’t come pre-installed in collab. So we need to install it externally using pip.

Step – 3 : Now we will install our required missing module/package using the following syntax.

!pip install <module_name>

 

Step 4 : After successful execution of the cell try to reimport it or run the previous cell to check if it has installed properly or not.

 

Now we can see the green check mark on the left side of the cell , which indicates it has executed properly without any error and the module has been installed properly.



Next Article
Smart calculator in Python

R

RaunakKondiboyina
Improve
Article Tags :
  • Machine Learning
  • Python Programs
  • python
Practice Tags :
  • Machine Learning
  • python

Similar Reads

  • How to use Google Colab
    If you want to create a machine learning model but say you don't have a computer that can take the workload, Google Colab is the platform for you. In this article, we'll learn how to use google colab. What is Google Colab? Google Colab, short for Colaboratory, is a free cloud-based platform provided
    5 min read
  • How Can I Make One Python File Run Another File?
    In Python programming, there often arises the need to execute one Python file from within another. This could be for modularity, reusability, or simply for the sake of organization. In this article, we will explore different approaches to achieve this task, each with its advantages and use cases. Ma
    2 min read
  • Smart calculator in Python
    Problem - This smart calculator works on the text statement also. The user need not provide algebraic expression always. It fetches the word form the command (given by the user) and then formulates the expression.Examples: Input : Hi calculator plz find the lcm of 4 and 8. Output : 8 Input : Hi smar
    2 min read
  • How to fix "SyntaxError: invalid character" in Python
    This error happens when the Python interpreter encounters characters that are not valid in Python syntax. Common examples include: Non-ASCII characters, such as invisible Unicode characters or non-breaking spaces.Special characters like curly quotes (“, ”) or other unexpected symbols.How to Resolve:
    2 min read
  • Download Anything to Google Drive using Google colab
    When we download/upload something from a cloud server, it gives more transfer rate as compared to a normal server. We can use Google Drive for storage as well as fast speed download. The problem is how to upload something to G-Drive direct from Internet. So, Here we will see a solution to upload any
    2 min read
  • Python | Automate Google Search using Selenium
    Google search can be automated using Python script in just 2 minutes. This can be done using selenium (a browser automation tool). Selenium is a portable framework for testing web applications. It can automatically perform the same interactions that any you need to perform manually and this is a sma
    3 min read
  • Python Tutorial | Learn Python Programming Language
    Python Tutorial – Python is one of the most popular programming languages. It’s simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly. Python is: A high-level language, used in web development, data science, automat
    10 min read
  • Create a Pyd File in Python
    A Pyd file, also known as a Python Dynamic Module, is a compiled Python extension module with the .pyd extension. It is equivalent to a DLL (Dynamic Link Library) on Windows and a shared library on other platforms. Pyd files contain compiled Python code, allowing you to create high-performance exten
    3 min read
  • Running Python program in the background
    Let us see how to run a Python program or project in the background i.e. the program will start running from the moment device is on and stop at shut down or when you close it. Just run one time to assure the program is error-bug free One way is to use pythonw, pythonw is the concatenation of python
    3 min read
  • Saving API Result Into JSON File in Python
    As Python continues to be a prominent language for web development and data processing, working with APIs and storing the obtained data in a structured format like JSON is a common requirement. In this article, we will see how we can save the API result into a JSON file in Python. Saving API Result
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences