SlideShare ist ein Scribd-Unternehmen logo
1 von 8
Downloaden Sie, um offline zu lesen
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

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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@
 

Kürzlich hochgeladen (20)

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...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+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