MISSION 97

Command Line Python Scripting

We looked at the command line Python interpreter in the last mission. The interpreter lets us run Python commands and see their results immediately. It's very useful for quickly testing snippets of code, as well as debugging. But it's not a good way to develop Python programs, because the commands aren't saved anywhere.

In order to develop Python programs, we'll need to make files containing Python code. Then we'll be able to use the interpreter to run them from the command line. This way, we can save all of our commands and still see what's happening.

This is a very common way to develop with Python — use an IDE or text editor to create Python files, then run them from the command line.

We can make a file that Python can execute on the command line by adding some lines of Python code to a blank text file.

In this mission, you will learn how to create and run Python scripts using the command line. You will also learn about virtual environments and how they can be used to keep a set of packages isolated from another environment to prevent conflicts.

As you work through each concept, you’ll get to apply what you’ve learned from within your browser so that there's no need to use your own machine to do the exercises. The command line environment inside of this course includes answer checking so you can ensure that you've fully mastered each concept before learning the next concept.

Objectives

  • The basics of command line Python.
  • Learn to install new Python packages using pip.
  • What virtual environments are and how to use them.

Mission Outline

1. Introduction to Command Line Python
2. Using Different Python Versions
3. Installing Packages that Extend Python
4. Overview of Virtual Environments
5. Creating a Python 3 virtualenv
6. Activating a virtualenv
7. Verifying the Installed Packages
8. Importing Saved Functions into a File
9. Accessing Command Line Arguments
10. Deactivating a virtualenv
11. Takeaways

command-line-beginner

Course Info:

Beginner

The median completion time for this course is 6.12 hours. View details

This course requires a basic subscription. It includes six missions, and three guided projects It is the eighth course in the Data Analyst in Python path and Data Scientist in Python path.

START LEARNING FREE

Take a Look Inside