SlideShare a Scribd company logo
1 of 8
Download to read offline
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

More Related Content

Viewers also liked

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
 

Viewers also liked (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
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
 
куклы в интерьере
куклы в интерьерекуклы в интерьере
куклы в интерьере
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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