Skip to content

usc-isi-i2/DSCI-510-Fall-2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

DSCI-510-Fall-2024 - Getting Started

This document explains the things required to get started with programming in python.

Create a Github account

All students should have a github account, use this link to sign up for a new account in case you do not have one.

Conda: Installation and Virtual Environment setup

For Windows

For Mac

For Linux

NOTE: The following commands are run in a terminal.

Creating a virtual environment

Students should create a virtual environment for each assignment, and project in general. This is a good python programming practice. For example, to create a virtual environment for lab assignemnt 1,

conda create -n dsci-510 python=3.10 -y

Creates a conda virtual environment called dsci-510 and the major python version is 3.10

Activate the conda environment

conda activate dsci-510

You should see something similar to this ,

D22ML-AMANDEEP:~ amandeep$ conda activate dsci-510
(dsci-510) D22ML-AMANDEEP:~ amandeep$

The (dsci-510) means that the conda environment: dsci-510 is active.

Check python version

python --version

Output should be similar to this ,

(dsci-510) D22ML-AMANDEEP:~ amandeep$ python --version
Python 3.10.12

Start Python Shell

Typing the following command in the terminal starts the interactive python shell

python

The output of the above command should be similar to this ,

(dsci-510) D22ML-AMANDEEP:~ amandeep$ python
Python 3.10.12 (main, Jul  5 2023, 15:02:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now we are ready to write some code

(dsci-510) D22ML-AMANDEEP:~ amandeep$ python
Python 3.10.12 (main, Jul  5 2023, 15:02:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1
>>> y = x + 5
>>> x
1
>>> y
6
>>> y += 10
>>> y
16
>>>

Press Enter to execute a line in the python shell.

IDE Recommendation

Students can download a one year free license for PyCharm with USC email id. I use PyCharm myself in my projects. You do not have to use PyCharm, any text editor would work.

Installing Jupyter Lab

Jupyter lab provides a web based interactive development environment. Install jupyter lab by running this command, in the terminal ,

pip install jupyterlab

You will have to register your conda environment with Jupyter before it can be used in the jupyter notebooks. If the conda environment is called dsci-510, run the following command to register this conda environment with Jupter ,

python -m ipykernel install --name dsci-510 --display-name dsci-510

Finally, run jupyter lab by typing the following command ,

jupyter lab

You should see output similar to this ,

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[I 2023-08-14 16:53:33.035 ServerApp] nbclassic | extension was successfully loaded.
[I 2023-08-14 16:53:33.035 ServerApp] Serving notebooks from local directory: /Users/amandeep/Downloads/DSCI 510 - Fall 2022/lectures/week 1
[I 2023-08-14 16:53:33.036 ServerApp] Jupyter Server 2.1.0 is running at:
[I 2023-08-14 16:53:33.036 ServerApp] http://localhost:8888/lab?token=ddb241eb40394243ea17d0bb252d89d3d973bc198c2780b5
[I 2023-08-14 16:53:33.036 ServerApp]  or http://127.0.0.1:8888/lab?token=ddb241eb40394243ea17d0bb252d89d3d973bc198c2780b5
[I 2023-08-14 16:53:33.036 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-08-14 16:53:33.038 ServerApp]

    To access the server, open this file in a browser:
        file:///Users/amandeep/Library/Jupyter/runtime/jpserver-48598-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=ddb241eb40394243ea17d0bb252d89d3d973bc198c2780b5
     or http://127.0.0.1:8888/lab?token=ddb241eb40394243ea17d0bb252d89d3d973bc198c2780b5
[I 2023-08-14 16:53:36.114 LabApp] Build is up to date

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published