{"id":3281,"date":"2022-08-16T13:24:22","date_gmt":"2022-08-16T13:24:22","guid":{"rendered":"https:\/\/arzhost.com\/blogs\/?p=3281"},"modified":"2025-09-25T15:24:43","modified_gmt":"2025-09-25T10:24:43","slug":"create-a-virtualenv-in-python","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/create-a-virtualenv-in-python\/","title":{"rendered":"How to Create a Virtualenv in Python"},"content":{"rendered":"<p>Today here at <a href=\"https:\/\/arzhost.com\/\">Arzhost<\/a>, we discuss how we <span style=\"color: #000000;\"><strong>create new virtualenv python<\/strong><\/span> in our windows or Linux. Applications written in Python frequently employ packages and other modules that aren&#8217;t included in the standard library. Applications may occasionally need a specific version of the library to complete a job or resolve a defect. How to Create a Virtualenv in Python?<\/p>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/ohlRbcasPAc\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/create-a-virtualenv-in-python\/#Creating_Virtual_Environments_is_Important\" >Creating Virtual Environments is Important<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/create-a-virtualenv-in-python\/#Construction_of_a_Virtual_Environment\" >Construction of a Virtual Environment<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Creating_Virtual_Environments_is_Important\"><\/span><strong>Creating Virtual Environments is Important<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let&#8217;s say we are creating two applications that need an older version of the library while other applications in the same <strong>Python installation<\/strong> need a newer version. It can occasionally result in a problem.<\/p>\n<p>In other words, not every application&#8217;s needs may be met by a single <a href=\"https:\/\/en.wikipedia.org\/wiki\/Python_(programming_language)\" target=\"_blank\" rel=\"noopener\">Python<\/a> installation. Conflicts between the requirements of different applications may arise. For instance, if application A needs version 1.0 and application B needs version 2.0, a conflict will develop and one application won&#8217;t be able to execute.<\/p>\n<p>Python offers to create a <strong>new virtualenv python<\/strong> in order to satisfy this conflicting requirement. Version 1.0 is the environment for Application A. Application B&#8217;s environment is version 2.0, so if we upgrade Application B to Version 3.0, Application A&#8217;s environment won&#8217;t be impacte.<\/p>\n<p><a href=\"https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone  wp-image-13896\" title=\"creating virtual environments is important\" src=\"https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important-300x157.jpg\" alt=\"creating virtual environments is important\" width=\"730\" height=\"382\" srcset=\"https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important-300x157.jpg 300w, https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important-1024x536.jpg 1024w, https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important-768x402.jpg 768w, https:\/\/arzhost.com\/blogs\/wp-content\/uploads\/2025\/09\/creating-virtual-environments-is-important.jpg 1200w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Construction_of_a_Virtual_Environment\"><\/span><strong>Construction of a Virtual Environment<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A virtual environment is create and manage using the venv module. It works with the latest Python version. To establish a virtual environment, choose a location, and run the venv module as handwriting using the directory path. In your command line, enter the following command after typing it.<\/p>\n<ul>\n<li><code>Python3 -m new-env venv<\/code><\/li>\n<\/ul>\n<p>The above-mentioned command will construct the new-env directory as well as a directory holding a fresh instance of the Python interpreter inside the newly established virtual environment new-env.<\/p>\n<p>The venv folder in the shared directory location houses all virtual environments. The virtual environment must be activate when it has been create by typing the next command.<\/p>\n<ul>\n<li><code>After entering on Window, press enter.<\/code><\/li>\n<li><code>new-env\\Scripts\\activate.bat<\/code><\/li>\n<\/ul>\n<p><strong>Run: on UNIX or macOS.<\/strong><\/p>\n<ul>\n<li><code>new-env\/bin\/activate as a source<\/code><\/li>\n<\/ul>\n<p>The shell prompts will change after the virtual environment is activate. create a new virtualenv python indicating which virtual environment we are using.<\/p>\n<ul>\n<li><code>Package management with pip<\/code><\/li>\n<\/ul>\n<p>Using the Python package manager pip, we may install, upgrade, and uninstall libraries in an active virtual environment. For instance \u2013<\/p>\n<ol>\n<li><code>New-env) $ pip install requests==2.6.0<\/code><\/li>\n<li><code>Collecting requests==2.6.0<\/code><\/li>\n<li><code>Using cached requests-2.6.0-py2.py3-none-any.whl<\/code><\/li>\n<li><code>Installing collected packages: requests<\/code><\/li>\n<li><code>Successfully installed requests-2.6.0<\/code><\/li>\n<\/ol>\n<p>If we re-run the previous command. It will display the required version is already install. Visit <a href=\"http:\/\/www.arzhost.com\">www.arzhost.com<\/a> for more queries.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today here at Arzhost, we discuss how we create new virtualenv python in our windows or Linux. Applications written in Python frequently employ packages and other modules that aren&#8217;t included in the standard library. Applications may occasionally need a specific version of the library to complete a job or resolve a defect. How to Create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6506,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,29],"tags":[],"table_tags":[],"class_list":["post-3281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","category-python"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/3281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=3281"}],"version-history":[{"count":5,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/3281\/revisions"}],"predecessor-version":[{"id":13897,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/3281\/revisions\/13897"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/6506"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=3281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=3281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=3281"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=3281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}