{"id":360,"date":"2022-06-03T00:35:56","date_gmt":"2022-06-02T19:05:56","guid":{"rendered":"https:\/\/ashokaon.tech\/blog\/?p=360"},"modified":"2022-06-03T00:43:54","modified_gmt":"2022-06-02T19:13:54","slug":"how-to-setup-a-python-virtual-environment","status":"publish","type":"post","link":"https:\/\/ashokaon.tech\/blog\/how-to-setup-a-python-virtual-environment\/","title":{"rendered":"{ForMyFutureQuickReference}-How to setup a Python Virtual Environment"},"content":{"rendered":"<blockquote><p><em>Posts with {ForMyFutureQuickReference} tag are, as the name suggests, for my future quick reference. These posts could also help others, it&#8217;s a plus if it does.<\/em><\/p><\/blockquote>\n<p>Instead of depending on the machine level global python installation and packages, you can have a project\/application specific set of\u00a0 python interpreter &amp; packages. The benefit is, you get an isolated python development environment for each of your development projects. You do this by creating a Python Virtual Environment.<\/p>\n<p>The following command will create a Python Virtual Environment.<\/p>\n<pre>python -m venv env1<\/pre>\n<p>env1 is the Virtual Environment name.<\/p>\n<p>A folder gets created as env1 and it will contain the python interpreter and default libraries. You need to activate the virtual environment by:<\/p>\n<p>.\\env1\\Scripts\\activate<\/p>\n<p>Now you will get a prompt as below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-368 \" src=\"https:\/\/ashokaon.tech\/blog\/wp-content\/uploads\/prompt2.png\" alt=\"\" width=\"468\" height=\"64\" srcset=\"https:\/\/ashokaon.tech\/blog\/wp-content\/uploads\/prompt2.png 857w, https:\/\/ashokaon.tech\/blog\/wp-content\/uploads\/prompt2-300x41.png 300w, https:\/\/ashokaon.tech\/blog\/wp-content\/uploads\/prompt2-768x105.png 768w\" sizes=\"(max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>Notice the &#8220;(env1)&#8221;, now whatever python packages you install will go into this virtual environment, until you issue the &#8220;deactivate&#8221; command to come out of the Virtual Environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Posts with {ForMyFutureQuickReference} tag are, as the name suggests, for my future quick reference. These posts could also help others, it&#8217;s a plus if it does. Instead of depending on the machine level global python installation and packages, you can have a project\/application specific set of\u00a0 python interpreter &amp; packages.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[54,52,53],"_links":{"self":[{"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/posts\/360"}],"collection":[{"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":12,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":377,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/377"}],"wp:attachment":[{"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ashokaon.tech\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}