SlideShare a Scribd company logo
1 of 18
VirtualEnv and Pip
Isolated Python environments
             Ryan Blunden
   Brisbane Python Group, May 2011
Summary
• Global site-packages management
• Per project package management
• VirtualEnv creates isolated Py envs
• VirtualEnvWrapper makes things easy
• Pip to install your packages
• Next... Automate your deploys
About Me
•   Have been the Front End Tech Lead at Flight Centre

•   Interested in all things web and am a fan of the new
    RESTful back-end => thick client movement

•   Python at work for back office and Systems Admin tasks.
    Don’t get why SA’s love bash scripts so much

•   Can’t build Django apps at work so I build them for
    myself and external clients

•   I’m hardly a Python expert, but I love it!
Global Package Management
•   Starts out fine

•   Overtime, things get messy

•   Not great for development in teams (sync issues)

•   Challenges in keeping dev, stage and prod environments
    in sync

•   Sometimes you don’t even have control of the prod
    global site packages

•   Easy for things to break overtime when versions and
    dependencies not clearly set
Per Project Packages
•   Enter virtualenv, a tool for creating isolated Python
    environments

•   Better than workingenv as it doesn’t rely on
    $PYTHONPATH trickery

•   Better than virtual-python as it works on Windows
    (doesn’t rely on symlinks)

•   Any of these are better than nothing, I just think
    virtualenv does it best.

•   Version 1.6.1 supports PyPy 1.5. PyPy!
Installing virtualenv
•   sudo easy_install virtualenv, then add this to your .bashrc

•   Create a new Python environment

    •   virtualenv myproject --no-site-packages
        Don’t inherit from global site-packages directory

    •   virtualenv myproject --no-site-packages --distribute
        Uses distribute instead of setup_tools

    •   I think it’s best to ensure your new env does not inherit
        packages from your global site-packages directory

•   This is ok but to make things easier to manage, let’s use
    virtualenvwrapper (Thanks Doug Hellmann)
virtualenvwrapper
•   Organises your virtualenvs into one spot
    # Put this in your .bash_profile or .bashrc
    export WORKON_HOME=$HOME/.virtualenvs
    source /usr/local/bin/virtualenvwrapper_bashrc



•   Separates your virtualenvs from your project source

•   Nice environment event hooks for automation of
    repetitive tasks (cd project on post_activate)

•   Basically, it makes your use of virtualenv more efficient

•   Now we need the perfect package management tool for
    installing packages in our env...
VirtualEnvWrapper scripts
•   mkvirtualenv (create a new virtualenv)

•   rmvirtualenv (remove an existing virtualenv)

•   workon (change the current virtualenv)

•   add2virtualenv (add external packages in a .pth file to current
    virtualenv)

•   cdsitepackages (cd into the site-packages directory of current
    virtualenv)

•   cdvirtualenv (cd into the root of the current virtualenv)

•   deactivate (deactivate virtualenv, which calls several hooks)
Virtual EnvWrapper Hooks
•   postmkvirtualenv

•   prermvirtualenv

•   postrmvirtualenv

•   postactivate

•   predeactivate

•   postdeactivate
Introducing pip
•   Pip - Pip Installs Packages, nothing more, nothing less

•   It’s good, James Bennet explains - http://goo.gl/F9m2N

•   Great at re-producing builds of specific versions of
    packages, just remember to use versioning for each
    package.

•   Every project needs at least one requirements file
Installing packages
•   By default, searches PyPi just like easy_install

•   Can also install from:
    - tarballs containing a setup.py script
    - Editable checkouts from VCS repos
    - Editable checkouts from VCS repos with revision info

•   Can install packages from Pip bundles
Installing packages
•   Installation - sudo easy_install pip

•   Workflow
    1. Make or activate virtual env
    2. Install (and search for) packages

•   pip search
    pip install package-name (latest)
    pip install package-name==1.4.5 (specific)
    pip install package-name>=1.4.5 (at least...)

•   Install packages from requirements file
    pip install -r requirements.txt

•   Freeze current packages to produce requirements file
Terminal action!

• Finally, let’s write some code
• For those watching at home, go checkout
  Mathemtism’s excellent screen cast at
  http://goo.gl/wWkti
What about my editor?

•   Good Python editors and IDE’s should support
    virtual env

•   PyCharm does by you telling it which python
    interpreter should be used for each project, it then
    nows which site packages directory to use.
Summary

• Isolated Python environments are a must
• VirtualEnv,VirtualEnvWrapper are THE way
  to manage them
Docs

•   VirtualEnv
    http://www.virtualenv.org/en/latest/

•   VirtualEnvWrapper
    http://www.doughellmann.com/docs/virtualenvwrapper/

•   Pip
    http://www.pip-installer.org/en/latest/
References
•   Pip and VirtualEnv (Awesome!)
    http://mathematism.com/2009/07/30/presentation-pip-
    and-virtualenv/

•   Tools of the Modern Python Hacker:Virtualenv, Fabric
    and Pip
    http://www.clemesha.org/blog/modern-python-hacker-
    tools-virtualenv-fabric-pip

•   Notes on using pip and virtualenv with Django
    http://www.saltycrane.com/blog/2009/05/notes-using-pip-
    and-virtualenv-django/
Thanks!

• Ryan Blunden
  ryan.blunden@gmail.com
  @ryan_blunden

More Related Content

Viewers also liked

2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates
2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates
2014_07_28_Django環境安裝以及 Django Book Chapter 4: TemplatesKe Wei Louis
 
Jenkins djangovillage
Jenkins djangovillageJenkins djangovillage
Jenkins djangovillageLucio Grenzi
 
Virtualenv
VirtualenvVirtualenv
VirtualenvWEBdeBS
 
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
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolutionTatiana Al-Chueyr
 
Current State of Python Packaging
Current State of Python PackagingCurrent State of Python Packaging
Current State of Python PackagingClayton Parker
 
Using Python Packages - An Overview
Using Python Packages - An OverviewUsing Python Packages - An Overview
Using Python Packages - An OverviewDaniel Hepper
 
Function calling convention
Function calling conventionFunction calling convention
Function calling conventionYuk SeungChan
 
Django in Production
Django in ProductionDjango in Production
Django in ProductionHyun-woo Park
 
Django sharing
Django sharingDjango sharing
Django sharingTom Chen
 
Django와 flask
Django와 flaskDjango와 flask
Django와 flaskJiho Lee
 
Django, 저는 이렇게 씁니다.
Django, 저는 이렇게 씁니다.Django, 저는 이렇게 씁니다.
Django, 저는 이렇게 씁니다.Kyoung Up Jung
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best PracticesDavid Arcos
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 

Viewers also liked (17)

2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates
2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates
2014_07_28_Django環境安裝以及 Django Book Chapter 4: Templates
 
Jenkins djangovillage
Jenkins djangovillageJenkins djangovillage
Jenkins djangovillage
 
Virtualenv
VirtualenvVirtualenv
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 & more
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
Current State of Python Packaging
Current State of Python PackagingCurrent State of Python Packaging
Current State of Python Packaging
 
Django Deployment-in-AWS
Django Deployment-in-AWSDjango Deployment-in-AWS
Django Deployment-in-AWS
 
Using Python Packages - An Overview
Using Python Packages - An OverviewUsing Python Packages - An Overview
Using Python Packages - An Overview
 
Stack frame
Stack frameStack frame
Stack frame
 
Function calling convention
Function calling conventionFunction calling convention
Function calling convention
 
Django in Production
Django in ProductionDjango in Production
Django in Production
 
Django sharing
Django sharingDjango sharing
Django sharing
 
Django와 flask
Django와 flaskDjango와 flask
Django와 flask
 
Django, 저는 이렇게 씁니다.
Django, 저는 이렇게 씁니다.Django, 저는 이렇게 씁니다.
Django, 저는 이렇게 씁니다.
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best Practices
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
Django quickstart
Django quickstartDjango quickstart
Django quickstart
 

More from Ryan Blunden

Container Camp Sydney 2017 Summary
Container Camp Sydney 2017 SummaryContainer Camp Sydney 2017 Summary
Container Camp Sydney 2017 SummaryRyan Blunden
 
Docker Multi-Stage Builds
Docker Multi-Stage BuildsDocker Multi-Stage Builds
Docker Multi-Stage BuildsRyan Blunden
 
Python typing module
Python typing modulePython typing module
Python typing moduleRyan Blunden
 
Transpiler’s are here to stay
Transpiler’s are here to stayTranspiler’s are here to stay
Transpiler’s are here to stayRyan Blunden
 
Promises in JavaScript with jQuery
Promises in JavaScript with jQueryPromises in JavaScript with jQuery
Promises in JavaScript with jQueryRyan Blunden
 
jQuery 1.4-1.6 Best new features
jQuery 1.4-1.6 Best new featuresjQuery 1.4-1.6 Best new features
jQuery 1.4-1.6 Best new featuresRyan Blunden
 

More from Ryan Blunden (6)

Container Camp Sydney 2017 Summary
Container Camp Sydney 2017 SummaryContainer Camp Sydney 2017 Summary
Container Camp Sydney 2017 Summary
 
Docker Multi-Stage Builds
Docker Multi-Stage BuildsDocker Multi-Stage Builds
Docker Multi-Stage Builds
 
Python typing module
Python typing modulePython typing module
Python typing module
 
Transpiler’s are here to stay
Transpiler’s are here to stayTranspiler’s are here to stay
Transpiler’s are here to stay
 
Promises in JavaScript with jQuery
Promises in JavaScript with jQueryPromises in JavaScript with jQuery
Promises in JavaScript with jQuery
 
jQuery 1.4-1.6 Best new features
jQuery 1.4-1.6 Best new featuresjQuery 1.4-1.6 Best new features
jQuery 1.4-1.6 Best new features
 

Recently uploaded

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

VirtualEnv and Pip - Isolated Python environments

  • 1. VirtualEnv and Pip Isolated Python environments Ryan Blunden Brisbane Python Group, May 2011
  • 2. Summary • Global site-packages management • Per project package management • VirtualEnv creates isolated Py envs • VirtualEnvWrapper makes things easy • Pip to install your packages • Next... Automate your deploys
  • 3. About Me • Have been the Front End Tech Lead at Flight Centre • Interested in all things web and am a fan of the new RESTful back-end => thick client movement • Python at work for back office and Systems Admin tasks. Don’t get why SA’s love bash scripts so much • Can’t build Django apps at work so I build them for myself and external clients • I’m hardly a Python expert, but I love it!
  • 4. Global Package Management • Starts out fine • Overtime, things get messy • Not great for development in teams (sync issues) • Challenges in keeping dev, stage and prod environments in sync • Sometimes you don’t even have control of the prod global site packages • Easy for things to break overtime when versions and dependencies not clearly set
  • 5. Per Project Packages • Enter virtualenv, a tool for creating isolated Python environments • Better than workingenv as it doesn’t rely on $PYTHONPATH trickery • Better than virtual-python as it works on Windows (doesn’t rely on symlinks) • Any of these are better than nothing, I just think virtualenv does it best. • Version 1.6.1 supports PyPy 1.5. PyPy!
  • 6. Installing virtualenv • sudo easy_install virtualenv, then add this to your .bashrc • Create a new Python environment • virtualenv myproject --no-site-packages Don’t inherit from global site-packages directory • virtualenv myproject --no-site-packages --distribute Uses distribute instead of setup_tools • I think it’s best to ensure your new env does not inherit packages from your global site-packages directory • This is ok but to make things easier to manage, let’s use virtualenvwrapper (Thanks Doug Hellmann)
  • 7. virtualenvwrapper • Organises your virtualenvs into one spot # Put this in your .bash_profile or .bashrc export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper_bashrc • Separates your virtualenvs from your project source • Nice environment event hooks for automation of repetitive tasks (cd project on post_activate) • Basically, it makes your use of virtualenv more efficient • Now we need the perfect package management tool for installing packages in our env...
  • 8. VirtualEnvWrapper scripts • mkvirtualenv (create a new virtualenv) • rmvirtualenv (remove an existing virtualenv) • workon (change the current virtualenv) • add2virtualenv (add external packages in a .pth file to current virtualenv) • cdsitepackages (cd into the site-packages directory of current virtualenv) • cdvirtualenv (cd into the root of the current virtualenv) • deactivate (deactivate virtualenv, which calls several hooks)
  • 9. Virtual EnvWrapper Hooks • postmkvirtualenv • prermvirtualenv • postrmvirtualenv • postactivate • predeactivate • postdeactivate
  • 10. Introducing pip • Pip - Pip Installs Packages, nothing more, nothing less • It’s good, James Bennet explains - http://goo.gl/F9m2N • Great at re-producing builds of specific versions of packages, just remember to use versioning for each package. • Every project needs at least one requirements file
  • 11. Installing packages • By default, searches PyPi just like easy_install • Can also install from: - tarballs containing a setup.py script - Editable checkouts from VCS repos - Editable checkouts from VCS repos with revision info • Can install packages from Pip bundles
  • 12. Installing packages • Installation - sudo easy_install pip • Workflow 1. Make or activate virtual env 2. Install (and search for) packages • pip search pip install package-name (latest) pip install package-name==1.4.5 (specific) pip install package-name>=1.4.5 (at least...) • Install packages from requirements file pip install -r requirements.txt • Freeze current packages to produce requirements file
  • 13. Terminal action! • Finally, let’s write some code • For those watching at home, go checkout Mathemtism’s excellent screen cast at http://goo.gl/wWkti
  • 14. What about my editor? • Good Python editors and IDE’s should support virtual env • PyCharm does by you telling it which python interpreter should be used for each project, it then nows which site packages directory to use.
  • 15. Summary • Isolated Python environments are a must • VirtualEnv,VirtualEnvWrapper are THE way to manage them
  • 16. Docs • VirtualEnv http://www.virtualenv.org/en/latest/ • VirtualEnvWrapper http://www.doughellmann.com/docs/virtualenvwrapper/ • Pip http://www.pip-installer.org/en/latest/
  • 17. References • Pip and VirtualEnv (Awesome!) http://mathematism.com/2009/07/30/presentation-pip- and-virtualenv/ • Tools of the Modern Python Hacker:Virtualenv, Fabric and Pip http://www.clemesha.org/blog/modern-python-hacker- tools-virtualenv-fabric-pip • Notes on using pip and virtualenv with Django http://www.saltycrane.com/blog/2009/05/notes-using-pip- and-virtualenv-django/
  • 18. Thanks! • Ryan Blunden ryan.blunden@gmail.com @ryan_blunden

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n