{"id":10,"date":"2025-04-10T21:13:43","date_gmt":"2025-04-10T13:13:43","guid":{"rendered":"https:\/\/jerrykhoo.com\/?p=10"},"modified":"2025-04-10T22:09:23","modified_gmt":"2025-04-10T14:09:23","slug":"setting-up-venv-for-python-apps-on-windows","status":"publish","type":"post","link":"https:\/\/jerrykhoo.com\/index.php\/2025\/04\/10\/setting-up-venv-for-python-apps-on-windows\/","title":{"rendered":"Setting up venv for python apps on Windows"},"content":{"rendered":"\n<p>Very often, we would like to try python apps that we find on Github on our local machine. Installing the dependencies associated with the app might mess our system.<\/p>\n\n\n\n<p>That&#8217;s where venv comes in. venv is a Python module that creates a unique environment for each task or project. It allows us to isolate the space for an app prevent the various dependencies we have to install for the app. This article is geared more towards python being installed on Windows OS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which python<\/code><\/pre>\n\n\n\n<p>First, we check which version of python we have, to make sure that we have python installed. We use this as a form of verification.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which pip<\/code><\/pre>\n\n\n\n<p>We follow this with which version of pip is installed. We do this because though Python3 usually comes with pip preinstalled, sometimes the installation may be an older version of pip.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install virtualenv<\/code><\/pre>\n\n\n\n<p>If venv is not installed, start a command prompt and run the above command.<\/p>\n\n\n\n<p>To start Virtualenv, head to your project location on your windows command prompt. We can create ta directory to hold the python app.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir myapp<\/code><\/pre>\n\n\n\n<p>Create a directory for the python app<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd myapp<\/code><\/pre>\n\n\n\n<p>Navigate to the directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>virtualenv myapp<\/code><\/pre>\n\n\n\n<p>Choose the name of your virtual environment<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Users\\&#039;Username&#039;\\venv\\Scripts\\activate.bat<\/code><\/pre>\n\n\n\n<p>Activate the virtual environment using the &#8220;activate.bat&#8221; located in the \\venv\\Scripts\\ directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(myenv) C:\\path\\to\\current\\directory<\/code><\/pre>\n\n\n\n<p>Once the virtual environment is activated, you&#8217;ll see the (myenv) at the beginning of the prompt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deactivate.bat<\/code><\/pre>\n\n\n\n<p>To de-activate the virtual environment, do the following<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Very often, we would like to try python apps that we find on Github on our local machine. Installing the dependencies associated with the app might mess our system. That&#8217;s where venv comes in. venv is a Python module that creates a unique environment for each task or project. It allows us to isolate the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","iawp_total_views":78,"footnotes":""},"categories":[],"tags":[3,4],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","tag-python","tag-venv"],"_links":{"self":[{"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":1,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":11,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/posts\/10\/revisions\/11"}],"wp:attachment":[{"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jerrykhoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}