SlideShare ist ein Scribd-Unternehmen logo
How to isolate
python installations
with virtualenv

Divick Kishore,
iWish Inc, www.iwishapp.com,
divick@iwishapp.com
When to use virtualenv?

● If you don't have sudo or root access on a
  development machine
● You want to try out a new package without
  polluting the system directories / global
  python installation
● You want to test your code with a new
  version of a library without uninstalling the
  previous version
● You want to test your code in an isolated
  environment before you deploy it to a
  production server
What is Virtualenv

● Tool to create isolated python environment
  quite like chroot jail on Unix systems
● Difference being that program running in
  chroot jail cannot access anything outside of
  chrooted folder while virtualenv allows
  installation of multiple versions of a single
  library
Virtualenv setup and usage

● Install Virtualenv
  $ pip install virtualenv

● Create a Virtualenv
  $ virtualenv --no-site-packages ve
   ○ The name of virtualenv can be anything you like
   ○ --no-site-packages is optional as it is the default
   ○ The way it works is by creating symlinks to your
     global python installation
● Use the isolated Python environment
   ○ To enter the environment run:
      $ source ./ve/bin/activate
      (ve) $
Enter the Virtualenv

● On entering the virtualenv, notice the
  command prompt change. It has a (ve) prefix
  now
     $ source ./ve/bin/activate
     (ve) $

● Before entering the virtualenv, see the list of
  packages installed
     $ pip freeze
     Brlapi==0.5.5
     CouchDB==0.8
     Django==1.3
     Fabric==1.3.4
     ...
Install packages in newly created
Virtualenv

● On entering the virtualenv, see the list of
  packages installed
     (ve) $ pip freeze
     (ve) $
   ○ As you can see above, there are no packages
     installed and you have a clean environment to begin
     testing
● Now you can install any package that you
  like which will get installed in the virtualenv
  've' that you just created
  (ve) $ pip install <package-name>
  (ve) $ pip install -r requirements.txt
Exit VirtualEnv

● Simply run
  (ve) $ deactivate
  $

● See the command prompt change back to $
  without 've' prefix
Summary

● Virtualenv and pip are must use tools for any
  python developer
● It seem daunting at first, but both Virtualenv
  and Pip are quite easy to setup and use
● Use Pip and Virtualenv in combination
  earlyon to avoid headaches in long run

Weitere ähnliche Inhalte

Andere mochten auch

Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CVBipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
BipinKumar Pal
 
TELiBrahma news_ outlook business
TELiBrahma news_ outlook businessTELiBrahma news_ outlook business
TELiBrahma news_ outlook business
Anjan Jayasimha
 
2013년 지부목표 및 슬로건
2013년 지부목표 및 슬로건2013년 지부목표 및 슬로건
2013년 지부목표 및 슬로건
Johney Kim
 
Rakhee Patnaik Resume
Rakhee Patnaik  Resume  Rakhee Patnaik  Resume
Rakhee Patnaik Resume
Rakhee Patnaik
 
Presentation222
Presentation222Presentation222
Presentation222
kolomas
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
saytina
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
saytina
 

Andere mochten auch (17)

La escuela es aburrida
La escuela es aburridaLa escuela es aburrida
La escuela es aburrida
 
Portafolio Manuel Ventura
Portafolio Manuel VenturaPortafolio Manuel Ventura
Portafolio Manuel Ventura
 
Food for thought
Food for thought Food for thought
Food for thought
 
Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CVBipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
Bipin Kumar_Pal_Pharmaceuticals_Assistant Manager_10+_CV
 
Charla a influencer
Charla a influencerCharla a influencer
Charla a influencer
 
Presentacion juventud y redes sociales centro juvenil scj
Presentacion juventud y redes sociales centro juvenil scjPresentacion juventud y redes sociales centro juvenil scj
Presentacion juventud y redes sociales centro juvenil scj
 
Entertainment
EntertainmentEntertainment
Entertainment
 
TELiBrahma news_ outlook business
TELiBrahma news_ outlook businessTELiBrahma news_ outlook business
TELiBrahma news_ outlook business
 
Vgt
VgtVgt
Vgt
 
короткое замыкание
короткое замыканиекороткое замыкание
короткое замыкание
 
2013년 지부목표 및 슬로건
2013년 지부목표 및 슬로건2013년 지부목표 및 슬로건
2013년 지부목표 및 슬로건
 
Rakhee Patnaik Resume
Rakhee Patnaik  Resume  Rakhee Patnaik  Resume
Rakhee Patnaik Resume
 
La escuela es aburrida esp
La escuela es aburrida espLa escuela es aburrida esp
La escuela es aburrida esp
 
Presentation222
Presentation222Presentation222
Presentation222
 
Teaching and learning together csun 2012
Teaching and learning together csun 2012Teaching and learning together csun 2012
Teaching and learning together csun 2012
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Buy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdfBuy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 

How to isolate python installations with virtualenv

  • 1. How to isolate python installations with virtualenv Divick Kishore, iWish Inc, www.iwishapp.com, divick@iwishapp.com
  • 2. When to use virtualenv? ● If you don't have sudo or root access on a development machine ● You want to try out a new package without polluting the system directories / global python installation ● You want to test your code with a new version of a library without uninstalling the previous version ● You want to test your code in an isolated environment before you deploy it to a production server
  • 3. What is Virtualenv ● Tool to create isolated python environment quite like chroot jail on Unix systems ● Difference being that program running in chroot jail cannot access anything outside of chrooted folder while virtualenv allows installation of multiple versions of a single library
  • 4. Virtualenv setup and usage ● Install Virtualenv $ pip install virtualenv ● Create a Virtualenv $ virtualenv --no-site-packages ve ○ The name of virtualenv can be anything you like ○ --no-site-packages is optional as it is the default ○ The way it works is by creating symlinks to your global python installation ● Use the isolated Python environment ○ To enter the environment run: $ source ./ve/bin/activate (ve) $
  • 5. Enter the Virtualenv ● On entering the virtualenv, notice the command prompt change. It has a (ve) prefix now $ source ./ve/bin/activate (ve) $ ● Before entering the virtualenv, see the list of packages installed $ pip freeze Brlapi==0.5.5 CouchDB==0.8 Django==1.3 Fabric==1.3.4 ...
  • 6. Install packages in newly created Virtualenv ● On entering the virtualenv, see the list of packages installed (ve) $ pip freeze (ve) $ ○ As you can see above, there are no packages installed and you have a clean environment to begin testing ● Now you can install any package that you like which will get installed in the virtualenv 've' that you just created (ve) $ pip install <package-name> (ve) $ pip install -r requirements.txt
  • 7. Exit VirtualEnv ● Simply run (ve) $ deactivate $ ● See the command prompt change back to $ without 've' prefix
  • 8. Summary ● Virtualenv and pip are must use tools for any python developer ● It seem daunting at first, but both Virtualenv and Pip are quite easy to setup and use ● Use Pip and Virtualenv in combination earlyon to avoid headaches in long run