Terminal and Python

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

-m what does this mean when you use it in terminal with Python?

This option instructs the Python interpreter to run a specified module as a script. In the below EXAMPLE, it tells Python to execute the `venv` module EXAMPLE ~ python3 -m venv my_env

What is the reason why you use virtual environments?

"no touchy the other stuffy" you make these self-contained Python environments with their. own Python interpreter and libraries which allows you to install and manage packages specific to your project without affecting your system-wide Python installation

#built-ins What are the steps to create a virtual environment in MacOS with a M1/M2 chip?

You will use the "venv" - a built in module that comes with Python: 1. Make a directory folder for your virtual environment a. by using the mkdir command 2. Navigate to that folder b. with the cd command 3. Create a virtual environment with the a. venv module and b. the -m which means "run this" 4. Activate it with the a. ven module again and b. the "source" command is used to run the script EXAMPLE $ mkdir my_virtual_environment $ cd my_virtual_environment my_virtual_environment $ python -m venv venv my_virtual_environment $ source venv/bin/activate (venv) my_virtual_environment $

How do you go to a directory level in terminal?

cd name_of_directory_here

How do I make a file, like a file_name.txt or filename.py in a directory from terminal?

either be in the directory and just use touch or use touch plus EXAMPLES touch app.py touch name_of_directory/new_text_file.txt

How do you list out what is in a directory (list out the folders?

ls

How do you make a directory in terminal?

mkdir

How do you move directories?

mv <source_directory><destination_directory>

What is the command to use terminal to open a text or python file?

open -a TextEdit app.tx Don't just use open app.tx b/c it won' t work there is no default. You have to use -a to tell it the application you want it to sue then point it to an app

How do you find out which directory you are in?

pwd

How do you remove/delete directories?

rmdir <directory>

How do you shut down an instance in a virtual environment in terminal?

the way to do this is to hit "control-c" on your keyboard go back into terminal - you will be prompted to "Shutdown this notebook server (y/n)?" and you hit "y"

What is the command to activate a virtual environment in Terminal?

you can use any name, here in this example we used "my_env" source my_env/bin/activate


Set pelajaran terkait

Business Computer Applications Midterm Exam Review

View Set

Ch.3 Exam - Health Insurance Policies: Medical Expense

View Set

Adaptive Learning Assignment: Chapter 15 - Databases

View Set

Introduction to Sociology (Chp. 1-10)

View Set

MBLEX - Massage Professional Practices

View Set

psych 161 chapter 9 and lecture 9

View Set

EAQ: hematology, anemia, neutropenia

View Set

bstrandable NCLEX Miscellaneous 2

View Set