We will be using Python for this course because it is open source and widely used in machine learning and data science. We will use Python 3 (in particular 3.7 or 3.8). Python 2 is not supported in this course.
We recommend the Anaconda Python distribution because it comes bundled with a bunch of useful packages (NumPy, SciPy, scikit-learn, Jupyter notebook) pre-installed. You can download Anaconda from their website for free.
For resources on learning Python, see the resources page.
A virtual environment is a Python environment such that the Python interpreter, libraries and scripts installed into it are isolated from those installed in other virtual environments, and (by default) any libraries installed in a “system” Python, i.e., one which is installed as part of your operating system. (https://docs.python.org/3/library/venv.html) For example, you may want a certain version of tensorflow for one project but another version for a different project. Virtual environments helps us to build environment isolation between different projects and make sure any change to dependencies affects only the projects that need it.
-
Option 1: Conda environments (preferred)
- Make sure that
conda
is installed by runningYou should see a list of environments as the output. If Anaconda/Miniconda is not installed, you can download Anaconda from here or Miniconda (a small, bootstrap version of Anaconda) from hereconda env list
- Download cpsc330env.yml and put it in your working directory
- Create an environment by
which allows
conda env create -f cpsc330env.yml
conda
to download the dependencies needed for this course and put them in a virtual environment namedcpsc330env
. You can check that the environemnt is installed successfully by runningconda env list
again.cpsc330env
should show up in the output. - Activate the environment with
After a successful activation, something like
conda activate cpsc330env
(cpsc330env)
should show up in the terminal. - We are all set! You can now run homework and lecture materials within the virtual environment.
jupyter lab
- To deactivate the environment, run
conda deactivate
For more information on conda environments, see here.
- Make sure that
-
Option 2:
Virtualenv
- You can choose this option if your have python version 3.7.x or 3.8.x installed on your system. To find out, run
python3 --version
- Install
Virtualenv
withpython3 -m pip install --user virtualenv
- Navigate to your working directory and create new virtual environment with
This will create a folder in your current directory that stores all the packages for this virtual environment.
virtualenv -p python3 cpsc330env
- Activate the environment
OS X/Linux:
Windows:
source cpsc330env/bin/activate
If you happen to use csh or fish shell, source the corresponding activate file. After a successful activation, something likecpsc330env\Scripts\activate
(cpsc330env)
should show up in the terminal. - Download requirements.txt and put it in your working directory. Then install the dependencies listed with
pip install -r requirements.txt
- A few more dependencies that we'll need to install manually
- We are all set! You can now run homework and lecture materials within the virtual environment.
jupyter lab
- To deactivate the virtual environment, run
deactivate
For more information on
virtualenv
, see here. - You can choose this option if your have python version 3.7.x or 3.8.x installed on your system. To find out, run
Activate the virtual environment, then run the following commands
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension update --all
jupyter lab build
Please also see the git setup instructions as you will need git as well for the course.