SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
The hitchhicker's guide to PIP
and Virtualenv (wrapper)...
Maybe...
Knowing where one's towel is




"Hey, you sass that hoopy Ford Prefect? There's a frood who really
knows where his towel is." (Sass: know, be aware of, meet, have sex
 with; hoopy: really together guy; frood: really amazingly together
                                guy.)
Index
   PIP                     virtual
                                  env

                      r
               r appe
        l envw
v irtua

              mabye...

and e
      veryt
            hing
                 :)

                    wers
                ans
Prerequisites
                                          It (maybe) works also
                                          in other *nix and
                                          with a little effort on
● Python :)                               Windows ;)


● linux ( unfortunately or fortunately :P )
● comfort with shell
● patience required
● internet connection ( not now, but we
   work on the web, in the coils of the Python! )
What is PIP?
      - pip installs packages. Python packages. -



pip is a tool for installing and
managing Python packages, such as
those found in the Python Package
Index (PyPI).
 
It’s a replacement for easy_install.
But...   what is Easy Install?

Easy Install is a python module
(easy_install) bundled with
setuptools that lets you
automatically download, build, install,
and manage Python packages.
 
So what?
            ea
              sy
                   _i
                     ns
    I P                ta
P                        ll
PIP installation
    Using package manager, the installer or from source

  (root)# apt-get install python-pip
# or
  (root)# curl http://python-distribute.org/distribute_setup.
py | python
  (root)# curl https://raw.github.
com/pypa/pip/master/contrib/get-pip.py | python
# or
  $ curl -O http://[...]/pip-1.0.tar.gz
  $ tar xvfz pip-x.y.tar.gz ; cd pip-1.0
# or
  $ git clone https://github.com/pypa/pip.git ; cd pip
  (root)# python setup.py install
PIP usage - base options
$ pip install SomePackage

   pip   install   /path/to/SomePackage.1.1.1.tar.gz
   pip   install   http://myrepo.it/SomePakage-1.4.0.zip
   pip   install   -e git+http://github.com/django/django.git#egg=django
   pip   install   -e path/to/SomePackage
   pip   install   django==1.1.1
                                                        ==, >=, >, <, <=
$ pip install --upgrade package-name


$ pip uninstall package-name                             another way for
                                                         querying installed
                                                         packages given from
$ pip search "query"                                     yolk


$ pip freeze > requirements.txt
                                                           Django==1.1.2
                                                           ipdb==0.2
$ pip install -r requirements.txt                          ipython==0.10.1
                                                           ...
PIP configuration
                        - quickest look -

*nix $HOME/.pip/pip.conf                           [global]
                                                   timeout = 60
windows %HOME%pippip.ini                         [freeze]
                                                   timeout = 10

$ export PIP_DEFAULT_TIMEOUT=10                    [install]
$ pip install django                               find-links =
                                                       http://mirror.com



 Env. variables
 override config file
                           Each command line options have a
                           PIP_<UPPER_NAME> environment variables



$ pip --default-timeout=60 install django
PyPI
                     - the Python Pakage Index -


 PyPI is a repository of software for Python
 and currently count 20481 packages.
 The PyPI repository provides alternative locations that store the
 packages.
  
                                             [install]
                                             use-mirrors = true
$ pip --use-mirrors ...                      mirrors =
$ export PIP_USE_MIRRORS=true                  http://d.pypi.python.org
                                               http://b.pypi.python.org




 You can create your own mirror, following the PEP 381 or using a tool
 such as pep381client
Want to know more?
           Read the docs!
            ( Luke! :D )




                      PIP
http://www.pip-installer.org/en/latest/index.html
WHY virtual environments?
●   Isolation - Python packages and even version live
    in their own 'planet' :)
●   Permissions - No sudoers, the environment is
    mine!!!
●   Organization - each project can maintain its own
    requirements file of Python packages.
●   No-Globalization - don't require installing stuff
    globally on the system.
PIP + virtualenv
●   it's not recommended install packages
    globally, but you can :)
●   pip works fine with virtualenv!
●   used in conjunction to isolate your
    installation


Well... step forward: setup and play with
           virtual environments!
What is virtualenv?
Is a tool to create isolated Python
environments.
 


Every virtualenv has pip installed in
it automatically (also easy_install)
under bin directory.
 


Does not require root access or
modify your system.
Installation

Using package manager, pip, the installer or using single file


  (root)# apt-get install python-virtualenv
# or
  (root)# pip install virtualenv
# or
  $ curl -O 
  https://raw.github.com/pypa/virtualenv/master/virtualenv.py
Basic Usage
                            $ virtualenv ENV


  This creates a folder ENV in the $PWD
  You'll find python packages on ENV/lib/pythonX.X/site-packages




                            Interesting options!



    $ virtualenv --no-site-packages --python=PYTHON_EXE ENV


Doesn't inherit global site-packages and use a different Python interpreter
Activate and Using ENV
$ cd ENV ; . bin/activate
(ENV) $ pip install django
Downloading/unpacking django
  Downloading Django-1.4.tar.gz (7.6Mb): 5.2Mb downloaded
...




      Also virtualenv has a config file
         and its looks like pip.conf
Extending virtualenv
# django-day.py
import virtualenv, textwrap
output = virtualenv.create_bootstrap_script(textwrap.
dedent())"""
def after_install(options, home_dir):
    subprocess.call([join(home_dir, 'bin', 'pip'),
       'install',
       'django'])
"""
f = open('django-bootstrap.py', 'w').write(output)



extend_parser(optparse_parser):
    # add or remove option          The script created is an
adjust_options(options, args):
    # change options or args
                                    extension to virtualenv
after_install(options, home_dir):   and inherit all its options!
    # after install run this
virtualenvwrapper
                         by Doug Hellmann

     is a set of extensions to Ian Bicking’s
     virtualenv tool for creating isolated
     Python development environments.
Features, taken verbatim from website:
●     Organizes all of your virtual environments in one place.
 ●    Wrappers for managing your virtual environments (create, delete, copy).
 ●    Use a single command to switch between environments.
 ●    Tab completion for commands that take a virtual environment as argument.
 ●    User-configurable hooks for all operations.
 ●    Plugin system for more creating sharable extensions.     Your homework ;)
Installation
           (root)# pip install virtualenvwrapper
           $ cd ~
           $ mkdir ~/.virtualenvs


Include environment vars needed into ~/.bashrc

           export    WORKON_HOME=$HOME/.virtualenvs
           source    /usr/local/bin/virtualenvwrapper.sh
           export    PIP_VIRTUALENV_BASE=$WORKON_HOME
           export    PIP_RESPECT_VIRTUALENV=true


A little tips: add to ~/.virtualenvs/postactivate

           export PYTHONPATH=$PYTHONPATH:$VIRTUAL_ENV
Basic Commands
   A brief introducion to manage virtual enviroment

$ mkvirtualenv --no-site-packages --python=PYTHON_EXE ENV
   # same as virtualenv!


$ workon ENV                     (ENV) $ cdvirtualenv
# set virtualenv environment     # go to home environment
(ENV) $


             (ENV) $ deactivate
             # deactivate current environment



             $ rmvirtualenv ENV
             # remove selected environment
More Commands :)
  (ENV) $ lssitepackages
  # list packages on current environment


  (ENV) $ cdsitepackages
  # go to site-packages directory


  (ENV) $ add2virtualenv directory...
  # adds the specified directories to the Python path


  (ENV) $ toggleglobalsitepackages
  # enable/disable global site-packages


                  Much more commands & options at
http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html
Simple Sample :P
$ mkvirtualenv --no-site-packages djangoday-rulez
(djangoday-rulez) $ deactivate
$ workon djangoday-rulez
(djangoday-rulez) $ cdvirtualenv
(djangoday-rulez) $ pip install django
... do some cool stuff ...
(djangoday-rulez) $ lssitepackages
(djangoday-rulez) $ deactivate
... do other stuff or switch project
... --- ...
... if it's not so cool ;) ...
$ rmvirtualenv djangoday-rulez
Tips & Hooks
         virtual environment with "requirements.txt" file
        $ mkvirtualenv --no-site-packages 
          --python=PYTHON_EXE -r django-requirements.txt



        $ mkvirtualenv --no-site-packages 
              -r other-requirements.txt



Under ~/.virtualenvs you'll find the hook scripts that running pre/post
create, activate environments.
                                                         postmkvirtualenv
Hooks are simply plain-text files with shell commands.   prermvirtualenv
You can customize them to change their behavior when an  postrmvirtualenv
                                                         postactivate
event occurs.                                            predeactivate
 
                                                         postdeactivate
See extending virtualenv-wrapper: http://bit.ly/IMP0vh
Not entirely unlike...




    virtualenv         virtualenvwrapper
                       http://bit.ly/141dCr
                  
http://bit.ly/jbFVCe
which python ?
Latest stable
2.4.6, 2.5.6,
 2.6.8, 2.7.3




Images comes from
    Wikipedia
pythonbrew !
pythonbrew is a program to automate the
building and installation of Python in the
users $HOME.
Installation
Recommended way

   $ curl -kL http://xrl.us/pythonbrewinstall | bash


 Add the following line into ~/.bashrc

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.
pythonbrew/etc/bashrc



                           Last News!!!
The original project seems to be unmantained, but there is
    a fork https://github.com/saghul/pythonz
(forked last week... Wait! I have a presentation to do! :D )
                  Long live pythonz!
Usage
                      Crash course!
$ pythonbrew install VERSION    $ pythonbrew off
   # install python VERSION        # turn off pythonbrew


$ pythonbrew list -k            $ pythonbrew use VERSION
   # list available pythons        # use specified python


$ pythonbrew list               $ pythonbrew uninstall VERSION
   # list installed pythons        # uninstall python VERSION


            $ pythonbrew switch VERSION
               # permanently use specified python
which python
$ pythonbrew use 2.6.5


$ which python
/home/cstrap/.pythonbrew/pythons/Python-2.5.6/bin/python

$ pythonbrew off


$ which python
/usr/bin/python



Cool! And you can create isolated python environments
                 (it uses virtualenv) ...
Create and use                 pythonbrew
                                             Always use
                                            the --force,
                                                Luke!
  $ pythonbrew install --force 2.5.6
  ... wait... This could take a while...
  $ pythonbrew use 2.5.6
  $ pythonbrew venv init
  $ pythonbrew venv create djangoday-proj
  $ pythonbrew venv list # list all environments
  $ pythonbrew venv use djangoday-proj
  (djangoday-proj) $ pip install django
  ... do some cool stuff ...




  ... if it's not so cool ;) ...
  $ pythonbrew venv delete djangoday-proj
Mostly Harmles...
●   virtualenv & virtualenvwrapper
    allow you to create and manage
    environments using the system default
    Python interpreter
●   pythonbrew allow you to install
    different Python interpreter, create
    and manage virtual environments


                     ...
Basic Combo
$ pythonbrew install --force 2.6.7
 ... wait...
$ mkvirtualenv --no-site-packages 
 -p $HOME/.pythonbrew/pythons/Python-2.6.7/bin/python
 djangoDay
 ... wait...
(djangoDay) $ cdvirtualenv
(djangoDay) [djangoDay] $ pip install django
... wait...
(djangoDay) $ which python ; python -V
/home/cstrap/.virtualenvs/djangoDay/bin/python
Python 2.6.7
(djangoDay) [djangoDay] $ deactivate
$ which python ; python -V
/usr/bin/python
Python 2.7.2
Super Combo
$ pythonbrew install --force 2.7.3 ... wait...
$ pythonbrew install --force 2.5.6 ... wait...
$ pythonbrew use 2.7.3
$ pip install virtualenv && pip install virtualenvwrapper
# configure .bashrc
export WORKON_HOME=$HOME/.virtualenvs
export 
VIRTUALENVWRAPPER_PYTHON=$HOME/.pythonbrew/pythons/Python-2.7.3/bin/python
source $HOME/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
$ mkdir ~/.virtualenvs
$ mkvirtualenv --no-site-packages 
   -p $HOME/.pythonbrew/pythons/Python-2.5.6/bin/python djangoDay
(djangoDay) $ which python ; python -V
/home/cstrap/.virtualenvs/djangoDay/bin/python
Python 2.5.6
(djangoDay) [djangoDay] $ deactivate
$ which python ; python -V
/home/cstrap/.pythonbrew/pythons/Python-2.7.3/bin/python
Python 2.7.3
$ pythonbrew off; python -V
# Your current system version of Python
Share and Enjoy! :P
lab@strap.it




         @cstrap
Answers?




Thanks for your patience! ;)

Contenu connexe

Tendances

Puppet DSL: back to the basics
Puppet DSL: back to the basicsPuppet DSL: back to the basics
Puppet DSL: back to the basicsJulien Pivotto
 
pip and virtualenv
pip and virtualenvpip and virtualenv
pip and virtualenvamaneu
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkinsmhelmich
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet
 
TYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CITYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CIderdanne
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamRachid Zarouali
 
uWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web appsuWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web appsTomislav Raseta
 
nginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottlenginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottleJordi Soucheiron
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementFelipe
 
Docker deploy
Docker deployDocker deploy
Docker deployEric Ahn
 
Introduction to IPython & Notebook
Introduction to IPython & NotebookIntroduction to IPython & Notebook
Introduction to IPython & NotebookAreski Belaid
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIEuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIMax Tepkeev
 
How to deliver a Python project
How to deliver a Python projectHow to deliver a Python project
How to deliver a Python projectmattjdavidson
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...Sebastian Neubauer
 
Installing OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xInstalling OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xNader Karimi
 

Tendances (20)

Vagrant and CentOS 7
Vagrant and CentOS 7Vagrant and CentOS 7
Vagrant and CentOS 7
 
Python environments
Python environmentsPython environments
Python environments
 
Puppet DSL: back to the basics
Puppet DSL: back to the basicsPuppet DSL: back to the basics
Puppet DSL: back to the basics
 
pip and virtualenv
pip and virtualenvpip and virtualenv
pip and virtualenv
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013
 
TYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CITYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CI
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
uWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web appsuWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web apps
 
nginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottlenginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottle
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration management
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 
Introduction to IPython & Notebook
Introduction to IPython & NotebookIntroduction to IPython & Notebook
Introduction to IPython & Notebook
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIEuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
 
How to deliver a Python project
How to deliver a Python projectHow to deliver a Python project
How to deliver a Python project
 
Fabric: A Capistrano Alternative
Fabric:  A Capistrano AlternativeFabric:  A Capistrano Alternative
Fabric: A Capistrano Alternative
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
 
Installing OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xInstalling OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.x
 

En vedette

We Buy Cheese in a Cheese Shop
We Buy Cheese in a Cheese ShopWe Buy Cheese in a Cheese Shop
We Buy Cheese in a Cheese ShopTzu-ping Chung
 
Python, Development Environment for Windows
Python, Development Environment for WindowsPython, Development Environment for Windows
Python, Development Environment for WindowsKwangyoun Jung
 
Python Recipes for django girls seoul
Python Recipes for django girls seoulPython Recipes for django girls seoul
Python Recipes for django girls seoulJoeun Park
 
Rabbitmq & Postgresql
Rabbitmq & PostgresqlRabbitmq & Postgresql
Rabbitmq & PostgresqlLucio Grenzi
 
The Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.pyThe Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.pyTzu-ping Chung
 
Django e il Rap Elia Contini
Django e il Rap Elia ContiniDjango e il Rap Elia Contini
Django e il Rap Elia ContiniWEBdeBS
 
Authentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVCAuthentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVCMindfire Solutions
 
NoSql Day - Apertura
NoSql Day - AperturaNoSql Day - Apertura
NoSql Day - AperturaWEBdeBS
 
Django mongodb -djangoday_
Django mongodb -djangoday_Django mongodb -djangoday_
Django mongodb -djangoday_WEBdeBS
 
2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to pythonJiho Lee
 
NoSql Day - Chiusura
NoSql Day - ChiusuraNoSql Day - Chiusura
NoSql Day - ChiusuraWEBdeBS
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at PyconOverview of Testing Talks at Pycon
Overview of Testing Talks at PyconJacqueline Kazil
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
The Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contribThe Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contribTzu-ping Chung
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework  for perfectionists with deadlinesDjango - The Web framework  for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlinesMarkus Zapke-Gründemann
 

En vedette (20)

We Buy Cheese in a Cheese Shop
We Buy Cheese in a Cheese ShopWe Buy Cheese in a Cheese Shop
We Buy Cheese in a Cheese Shop
 
Python, Development Environment for Windows
Python, Development Environment for WindowsPython, Development Environment for Windows
Python, Development Environment for Windows
 
Python Recipes for django girls seoul
Python Recipes for django girls seoulPython Recipes for django girls seoul
Python Recipes for django girls seoul
 
2 × 3 = 6
2 × 3 = 62 × 3 = 6
2 × 3 = 6
 
Rabbitmq & Postgresql
Rabbitmq & PostgresqlRabbitmq & Postgresql
Rabbitmq & Postgresql
 
The Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.pyThe Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.py
 
Django e il Rap Elia Contini
Django e il Rap Elia ContiniDjango e il Rap Elia Contini
Django e il Rap Elia Contini
 
Authentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVCAuthentication & Authorization in ASPdotNet MVC
Authentication & Authorization in ASPdotNet MVC
 
NoSql Day - Apertura
NoSql Day - AperturaNoSql Day - Apertura
NoSql Day - Apertura
 
Django mongodb -djangoday_
Django mongodb -djangoday_Django mongodb -djangoday_
Django mongodb -djangoday_
 
Bottle - Python Web Microframework
Bottle - Python Web MicroframeworkBottle - Python Web Microframework
Bottle - Python Web Microframework
 
2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python
 
NoSql Day - Chiusura
NoSql Day - ChiusuraNoSql Day - Chiusura
NoSql Day - Chiusura
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at PyconOverview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
 
EuroDjangoCon 2009 - Ein Rückblick
EuroDjangoCon 2009 - Ein RückblickEuroDjangoCon 2009 - Ein Rückblick
EuroDjangoCon 2009 - Ein Rückblick
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Django-Queryset
Django-QuerysetDjango-Queryset
Django-Queryset
 
The Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contribThe Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contrib
 
Digesting jQuery
Digesting jQueryDigesting jQuery
Digesting jQuery
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework  for perfectionists with deadlinesDjango - The Web framework  for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlines
 

Similaire à Virtualenv

Django district pip, virtualenv, virtualenv wrapper & more
Django district  pip, virtualenv, virtualenv wrapper & moreDjango district  pip, virtualenv, virtualenv wrapper & more
Django district pip, virtualenv, virtualenv wrapper & moreJacqueline Kazil
 
Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Ivan Chernoff
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolutionTatiana Al-Chueyr
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Codemotion
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvMarkus Zapke-Gründemann
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modulesKris Buytaert
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data scienceCalvin Giles
 
First python project
First python projectFirst python project
First python projectNeetu Jain
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionFabio Kung
 
Jenkins and Docker for native Linux packages
Jenkins and Docker for native Linux packagesJenkins and Docker for native Linux packages
Jenkins and Docker for native Linux packagesDaniel Paulus
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)zerok
 
Practical Pig and PigUnit (Michael Noll, Verisign)
Practical Pig and PigUnit (Michael Noll, Verisign)Practical Pig and PigUnit (Michael Noll, Verisign)
Practical Pig and PigUnit (Michael Noll, Verisign)Swiss Big Data User Group
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker, Inc.
 

Similaire à Virtualenv (20)

Django district pip, virtualenv, virtualenv wrapper & more
Django district  pip, virtualenv, virtualenv wrapper & moreDjango district  pip, virtualenv, virtualenv wrapper & more
Django district pip, virtualenv, virtualenv wrapper & more
 
Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
 
First python project
First python projectFirst python project
First python project
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to Production
 
Jenkins and Docker for native Linux packages
Jenkins and Docker for native Linux packagesJenkins and Docker for native Linux packages
Jenkins and Docker for native Linux packages
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
 
Python setup
Python setupPython setup
Python setup
 
Practical Pig and PigUnit (Michael Noll, Verisign)
Practical Pig and PigUnit (Michael Noll, Verisign)Practical Pig and PigUnit (Michael Noll, Verisign)
Practical Pig and PigUnit (Michael Noll, Verisign)
 
Python Projects at Neova
Python Projects at NeovaPython Projects at Neova
Python Projects at Neova
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 

Plus de WEBdeBS

Legal Pirlo
Legal PirloLegal Pirlo
Legal PirloWEBdeBS
 
Nodejsconf 2012
Nodejsconf 2012Nodejsconf 2012
Nodejsconf 2012WEBdeBS
 
Mockup, wireframe e visual: una breve introduzione
Mockup, wireframe e visual: una breve introduzioneMockup, wireframe e visual: una breve introduzione
Mockup, wireframe e visual: una breve introduzioneWEBdeBS
 
Djangoday lt 20120420
Djangoday lt 20120420Djangoday lt 20120420
Djangoday lt 20120420WEBdeBS
 
Unbit djangoday 20120419
Unbit djangoday 20120419Unbit djangoday 20120419
Unbit djangoday 20120419WEBdeBS
 
Iga workflow
Iga workflowIga workflow
Iga workflowWEBdeBS
 
PepperTweet - Project presentation Startup Weekend Brescia
PepperTweet - Project presentation Startup Weekend BresciaPepperTweet - Project presentation Startup Weekend Brescia
PepperTweet - Project presentation Startup Weekend BresciaWEBdeBS
 
Peppertweet - Presentazione Startup Weekend Brescia
Peppertweet - Presentazione Startup Weekend BresciaPeppertweet - Presentazione Startup Weekend Brescia
Peppertweet - Presentazione Startup Weekend BresciaWEBdeBS
 

Plus de WEBdeBS (10)

Legal Pirlo
Legal PirloLegal Pirlo
Legal Pirlo
 
Nodejsconf 2012
Nodejsconf 2012Nodejsconf 2012
Nodejsconf 2012
 
Mockup, wireframe e visual: una breve introduzione
Mockup, wireframe e visual: una breve introduzioneMockup, wireframe e visual: una breve introduzione
Mockup, wireframe e visual: una breve introduzione
 
Djangoday lt 20120420
Djangoday lt 20120420Djangoday lt 20120420
Djangoday lt 20120420
 
Unbit djangoday 20120419
Unbit djangoday 20120419Unbit djangoday 20120419
Unbit djangoday 20120419
 
Geodjango
GeodjangoGeodjango
Geodjango
 
Fagungis
FagungisFagungis
Fagungis
 
Iga workflow
Iga workflowIga workflow
Iga workflow
 
PepperTweet - Project presentation Startup Weekend Brescia
PepperTweet - Project presentation Startup Weekend BresciaPepperTweet - Project presentation Startup Weekend Brescia
PepperTweet - Project presentation Startup Weekend Brescia
 
Peppertweet - Presentazione Startup Weekend Brescia
Peppertweet - Presentazione Startup Weekend BresciaPeppertweet - Presentazione Startup Weekend Brescia
Peppertweet - Presentazione Startup Weekend Brescia
 

Dernier

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 

Dernier (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 

Virtualenv

  • 1. The hitchhicker's guide to PIP and Virtualenv (wrapper)... Maybe...
  • 2. Knowing where one's towel is "Hey, you sass that hoopy Ford Prefect? There's a frood who really knows where his towel is." (Sass: know, be aware of, meet, have sex with; hoopy: really together guy; frood: really amazingly together guy.)
  • 3. Index PIP virtual env r r appe l envw v irtua mabye... and e veryt hing :) wers ans
  • 4. Prerequisites It (maybe) works also in other *nix and with a little effort on ● Python :) Windows ;) ● linux ( unfortunately or fortunately :P ) ● comfort with shell ● patience required ● internet connection ( not now, but we work on the web, in the coils of the Python! )
  • 5. What is PIP? - pip installs packages. Python packages. - pip is a tool for installing and managing Python packages, such as those found in the Python Package Index (PyPI).   It’s a replacement for easy_install.
  • 6. But... what is Easy Install? Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages.  
  • 7. So what? ea sy _i ns I P ta P ll
  • 8.
  • 9. PIP installation Using package manager, the installer or from source (root)# apt-get install python-pip # or (root)# curl http://python-distribute.org/distribute_setup. py | python (root)# curl https://raw.github. com/pypa/pip/master/contrib/get-pip.py | python # or $ curl -O http://[...]/pip-1.0.tar.gz $ tar xvfz pip-x.y.tar.gz ; cd pip-1.0 # or $ git clone https://github.com/pypa/pip.git ; cd pip (root)# python setup.py install
  • 10. PIP usage - base options $ pip install SomePackage pip install /path/to/SomePackage.1.1.1.tar.gz pip install http://myrepo.it/SomePakage-1.4.0.zip pip install -e git+http://github.com/django/django.git#egg=django pip install -e path/to/SomePackage pip install django==1.1.1 ==, >=, >, <, <= $ pip install --upgrade package-name $ pip uninstall package-name another way for querying installed packages given from $ pip search "query" yolk $ pip freeze > requirements.txt Django==1.1.2 ipdb==0.2 $ pip install -r requirements.txt ipython==0.10.1 ...
  • 11. PIP configuration - quickest look - *nix $HOME/.pip/pip.conf [global] timeout = 60 windows %HOME%pippip.ini [freeze] timeout = 10 $ export PIP_DEFAULT_TIMEOUT=10 [install] $ pip install django find-links = http://mirror.com Env. variables override config file Each command line options have a PIP_<UPPER_NAME> environment variables $ pip --default-timeout=60 install django
  • 12. PyPI - the Python Pakage Index - PyPI is a repository of software for Python and currently count 20481 packages. The PyPI repository provides alternative locations that store the packages.   [install] use-mirrors = true $ pip --use-mirrors ... mirrors = $ export PIP_USE_MIRRORS=true http://d.pypi.python.org http://b.pypi.python.org You can create your own mirror, following the PEP 381 or using a tool such as pep381client
  • 13. Want to know more? Read the docs! ( Luke! :D ) PIP http://www.pip-installer.org/en/latest/index.html
  • 14. WHY virtual environments? ● Isolation - Python packages and even version live in their own 'planet' :) ● Permissions - No sudoers, the environment is mine!!! ● Organization - each project can maintain its own requirements file of Python packages. ● No-Globalization - don't require installing stuff globally on the system.
  • 15. PIP + virtualenv ● it's not recommended install packages globally, but you can :) ● pip works fine with virtualenv! ● used in conjunction to isolate your installation Well... step forward: setup and play with virtual environments!
  • 16. What is virtualenv? Is a tool to create isolated Python environments.   Every virtualenv has pip installed in it automatically (also easy_install) under bin directory.   Does not require root access or modify your system.
  • 17. Installation Using package manager, pip, the installer or using single file (root)# apt-get install python-virtualenv # or (root)# pip install virtualenv # or $ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
  • 18. Basic Usage $ virtualenv ENV This creates a folder ENV in the $PWD You'll find python packages on ENV/lib/pythonX.X/site-packages Interesting options! $ virtualenv --no-site-packages --python=PYTHON_EXE ENV Doesn't inherit global site-packages and use a different Python interpreter
  • 19. Activate and Using ENV $ cd ENV ; . bin/activate (ENV) $ pip install django Downloading/unpacking django Downloading Django-1.4.tar.gz (7.6Mb): 5.2Mb downloaded ... Also virtualenv has a config file and its looks like pip.conf
  • 20. Extending virtualenv # django-day.py import virtualenv, textwrap output = virtualenv.create_bootstrap_script(textwrap. dedent())""" def after_install(options, home_dir): subprocess.call([join(home_dir, 'bin', 'pip'), 'install', 'django']) """ f = open('django-bootstrap.py', 'w').write(output) extend_parser(optparse_parser): # add or remove option The script created is an adjust_options(options, args): # change options or args extension to virtualenv after_install(options, home_dir): and inherit all its options! # after install run this
  • 21.
  • 22. virtualenvwrapper by Doug Hellmann is a set of extensions to Ian Bicking’s virtualenv tool for creating isolated Python development environments. Features, taken verbatim from website: ● Organizes all of your virtual environments in one place. ● Wrappers for managing your virtual environments (create, delete, copy). ● Use a single command to switch between environments. ● Tab completion for commands that take a virtual environment as argument. ● User-configurable hooks for all operations. ● Plugin system for more creating sharable extensions. Your homework ;)
  • 23. Installation (root)# pip install virtualenvwrapper $ cd ~ $ mkdir ~/.virtualenvs Include environment vars needed into ~/.bashrc export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME export PIP_RESPECT_VIRTUALENV=true A little tips: add to ~/.virtualenvs/postactivate export PYTHONPATH=$PYTHONPATH:$VIRTUAL_ENV
  • 24. Basic Commands A brief introducion to manage virtual enviroment $ mkvirtualenv --no-site-packages --python=PYTHON_EXE ENV # same as virtualenv! $ workon ENV (ENV) $ cdvirtualenv # set virtualenv environment # go to home environment (ENV) $ (ENV) $ deactivate # deactivate current environment $ rmvirtualenv ENV # remove selected environment
  • 25. More Commands :) (ENV) $ lssitepackages # list packages on current environment (ENV) $ cdsitepackages # go to site-packages directory (ENV) $ add2virtualenv directory... # adds the specified directories to the Python path (ENV) $ toggleglobalsitepackages # enable/disable global site-packages Much more commands & options at http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html
  • 26. Simple Sample :P $ mkvirtualenv --no-site-packages djangoday-rulez (djangoday-rulez) $ deactivate $ workon djangoday-rulez (djangoday-rulez) $ cdvirtualenv (djangoday-rulez) $ pip install django ... do some cool stuff ... (djangoday-rulez) $ lssitepackages (djangoday-rulez) $ deactivate ... do other stuff or switch project ... --- ... ... if it's not so cool ;) ... $ rmvirtualenv djangoday-rulez
  • 27. Tips & Hooks virtual environment with "requirements.txt" file $ mkvirtualenv --no-site-packages --python=PYTHON_EXE -r django-requirements.txt $ mkvirtualenv --no-site-packages -r other-requirements.txt Under ~/.virtualenvs you'll find the hook scripts that running pre/post create, activate environments. postmkvirtualenv Hooks are simply plain-text files with shell commands. prermvirtualenv You can customize them to change their behavior when an postrmvirtualenv postactivate event occurs. predeactivate     postdeactivate See extending virtualenv-wrapper: http://bit.ly/IMP0vh
  • 28. Not entirely unlike... virtualenv   virtualenvwrapper http://bit.ly/141dCr   http://bit.ly/jbFVCe
  • 29. which python ? Latest stable 2.4.6, 2.5.6, 2.6.8, 2.7.3 Images comes from Wikipedia
  • 30.
  • 31. pythonbrew ! pythonbrew is a program to automate the building and installation of Python in the users $HOME.
  • 32. Installation Recommended way $ curl -kL http://xrl.us/pythonbrewinstall | bash Add the following line into ~/.bashrc [[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/. pythonbrew/etc/bashrc Last News!!! The original project seems to be unmantained, but there is a fork https://github.com/saghul/pythonz (forked last week... Wait! I have a presentation to do! :D ) Long live pythonz!
  • 33. Usage Crash course! $ pythonbrew install VERSION $ pythonbrew off # install python VERSION # turn off pythonbrew $ pythonbrew list -k $ pythonbrew use VERSION # list available pythons # use specified python $ pythonbrew list $ pythonbrew uninstall VERSION # list installed pythons # uninstall python VERSION $ pythonbrew switch VERSION # permanently use specified python
  • 34. which python $ pythonbrew use 2.6.5 $ which python /home/cstrap/.pythonbrew/pythons/Python-2.5.6/bin/python $ pythonbrew off $ which python /usr/bin/python Cool! And you can create isolated python environments (it uses virtualenv) ...
  • 35. Create and use pythonbrew Always use the --force, Luke! $ pythonbrew install --force 2.5.6 ... wait... This could take a while... $ pythonbrew use 2.5.6 $ pythonbrew venv init $ pythonbrew venv create djangoday-proj $ pythonbrew venv list # list all environments $ pythonbrew venv use djangoday-proj (djangoday-proj) $ pip install django ... do some cool stuff ... ... if it's not so cool ;) ... $ pythonbrew venv delete djangoday-proj
  • 36. Mostly Harmles... ● virtualenv & virtualenvwrapper allow you to create and manage environments using the system default Python interpreter ● pythonbrew allow you to install different Python interpreter, create and manage virtual environments ...
  • 37.
  • 38. Basic Combo $ pythonbrew install --force 2.6.7 ... wait... $ mkvirtualenv --no-site-packages -p $HOME/.pythonbrew/pythons/Python-2.6.7/bin/python djangoDay ... wait... (djangoDay) $ cdvirtualenv (djangoDay) [djangoDay] $ pip install django ... wait... (djangoDay) $ which python ; python -V /home/cstrap/.virtualenvs/djangoDay/bin/python Python 2.6.7 (djangoDay) [djangoDay] $ deactivate $ which python ; python -V /usr/bin/python Python 2.7.2
  • 39. Super Combo $ pythonbrew install --force 2.7.3 ... wait... $ pythonbrew install --force 2.5.6 ... wait... $ pythonbrew use 2.7.3 $ pip install virtualenv && pip install virtualenvwrapper # configure .bashrc export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=$HOME/.pythonbrew/pythons/Python-2.7.3/bin/python source $HOME/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME $ mkdir ~/.virtualenvs $ mkvirtualenv --no-site-packages -p $HOME/.pythonbrew/pythons/Python-2.5.6/bin/python djangoDay (djangoDay) $ which python ; python -V /home/cstrap/.virtualenvs/djangoDay/bin/python Python 2.5.6 (djangoDay) [djangoDay] $ deactivate $ which python ; python -V /home/cstrap/.pythonbrew/pythons/Python-2.7.3/bin/python Python 2.7.3 $ pythonbrew off; python -V # Your current system version of Python
  • 41. lab@strap.it @cstrap
  • 42. Answers? Thanks for your patience! ;)