CS1520 Recitation: VirtualENV Jeongmin Lee What is it Virtualenv - - PowerPoint PPT Presentation

cs1520 recitation virtualenv
SMART_READER_LITE
LIVE PREVIEW

CS1520 Recitation: VirtualENV Jeongmin Lee What is it Virtualenv - - PowerPoint PPT Presentation

CS1520 Recitation: VirtualENV Jeongmin Lee What is it Virtualenv is a tool to create isolated Python environments What is it Virtualenv is a tool to create isolated Python environments environments : version, dependencies, packages


slide-1
SLIDE 1

CS1520 Recitation: VirtualENV

Jeongmin Lee

slide-2
SLIDE 2

What is it

Virtualenv is a tool to create isolated Python environments

slide-3
SLIDE 3

What is it

Virtualenv is a tool to create isolated Python environments

  • environments : version, dependencies, packages (libraries) ..
slide-4
SLIDE 4

What is it

Virtualenv is a tool to create isolated Python environments

  • environments : version, dependencies, packages (libraries) ..
  • isolated : you can have multiple versions of pythons (2.7 / 3.6)

○ or different programs depends on different packages.. ○ Let’s separate environments!

slide-5
SLIDE 5

What is it

Virtualenv is a tool to create isolated Python environments

  • environments : version, dependencies, packages (libraries) ..
  • isolated : you can have multiple versions of pythons (2.7 / 3.6)

○ or different programs depends on different packages.. ○ Let’s separate environments!

Image: http://blog1.erp2py.com/2011/07/virtualenv.html

slide-6
SLIDE 6

Virtualenv

  • creates an environment that has its own installation

directories, that doesn’t share libraries with other virtualenv environments

  • (optionally) doesn’t access the globally installed libraries

either

slide-7
SLIDE 7

How to Install

  • Assuming that you have already installed python and pip

○ pip: package installer

  • Easy!

○ pip install virtaulenv ○ or, pip install virtualenv --user ■ It does not uses system-wide directory, but user-specific directory ○ test it! : virtualenv --version

slide-8
SLIDE 8

Create ENV

  • Create a virtual environment for a project:

○ cd my_project_folder ○ virtualenv my_project

slide-9
SLIDE 9

Create ENV

  • Create a virtual environment for a project:

○ cd my_project_folder ○ virtualenv my_project

  • virtualenv my_project will create a folder in the current

directory which will contain ○ the Python executable files ○ a copy of the pip library which you can use to install

  • ther packages
slide-10
SLIDE 10

Create ENV

  • You can specify the Python interpreter with different

versions: ○ >> virtualenv -p /usr/bin/python2.7 my_project ○ /usr/bin/python2.7 is the location of the Python interpreter

slide-11
SLIDE 11

Create ENV

  • If it doesn’t work (after installing on pip):

○ python -m virtualenv my_project ○ -m to allow modules to be located using the Python module namespace for execution as scripts

slide-12
SLIDE 12

Activate ENV

  • Activation is change the mode of current terminal

(command) to the environment.

  • After getting into the project folder first (by >> cd ...)
  • >> source my_env/bin/activate
slide-13
SLIDE 13

Deactivate

  • >> deactivate
slide-14
SLIDE 14

Reference

  • General Guide

○ https://virtualenv.pypa.io/en/stable/userguide/

  • Installation on Windows

○ http://www.tylerbutler.com/2012/05/how-to-install-python

  • pip-and-virtualenv-on-windows-with-powershell/
slide-15
SLIDE 15

Install PIP (windows)

  • Download

○ https://bootstrap.pypa.io/get-pip.py ○ python get-pip.py