{"id":1598,"date":"2026-09-12T15:49:06","date_gmt":"2026-09-12T15:49:06","guid":{"rendered":"https:\/\/nayananimsara.online\/?p=1598"},"modified":"2026-09-12T15:49:10","modified_gmt":"2026-09-12T15:49:10","slug":"how-to-create-python-virtual-environment-for-django","status":"publish","type":"post","link":"https:\/\/nayananimsara.online\/how-to-create-python-virtual-environment-for-django\/","title":{"rendered":"Python Virtual Environment: 4 Simple Steps to Create venv for Django (2026)"},"content":{"rendered":"\n<h1 class=\"wp-block-heading has-text-align-center\" id=\"python-virtual-environment-4-simple-steps-to-create-venv-for-django-2026\">Python Virtual Environment: 4 Simple Steps to Create venv for Django (2026)<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Welcome to video 3 of the Nima Academy Django course. Before installing Django itself, every professional Python developer sets up a <strong>Python virtual environment<\/strong> first. In this guide, you&#8217;ll learn exactly what venv is, why it matters, and how to create one in under 5 minutes \u2014 so your Django project stays clean and conflict-free.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#python-virtual-environment-4-simple-steps-to-create-venv-for-django-2026\">Python Virtual Environment: 4 Simple Steps to Create venv for Django (2026)<\/a><ul><li><a href=\"#why-you-need-a-python-virtual-environment-for-django\">Why You Need a Python Virtual Environment for Django<\/a><\/li><li><a href=\"#how-to-create-a-python-virtual-environment-step-by-step\">How to Create a Python Virtual Environment (Step-by-Step)<\/a><ul><li><a href=\"#step-1-open-terminal-in-your-project-folder\">Step 1: Open Terminal in Your Project Folder<\/a><\/li><li><a href=\"#step-2-create-the-virtual-environment-venv\">Step 2: Create the Virtual Environment (venv)<\/a><\/li><li><a href=\"#step-3-activate-the-virtual-environment\">Step 3: Activate the Virtual Environment<\/a><\/li><li><a href=\"#step-4-verify-and-install-packages-inside-venv\">Step 4: Verify and Install Packages Inside venv<\/a><\/li><\/ul><\/li><li><a href=\"#common-errors-when-setting-up-a-python-virtual-environment\">Common Errors When Setting Up a Python Virtual Environment<\/a><\/li><li><a href=\"#whats-next-in-the-django-course\">What&#8217;s Next in the Django Course<\/a><\/li><li><a href=\"#final-thoughts\">Final Thoughts<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">If you haven&#8217;t set up Python and VS Code yet, check out our <a href=\"https:\/\/nayananimsara.online\/install-python-and-vs-code-django-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">previous lesson on installing Python and VS Code<\/a> before continuing.<\/p>\n\n\n\n<h2 id=\"why-you-need-a-python-virtual-environment-for-django\" class=\"wp-block-heading\">Why You Need a Python Virtual Environment for Django<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every Python project you build will depend on specific packages and specific versions of those packages. Without isolation, installing Django for one project could break the dependencies of another project on your machine. A virtual environment solves this by creating a separate, self-contained folder for each project&#8217;s packages \u2014 so Django, and everything it needs, stays isolated from your system-wide Python installation.<\/p>\n\n\n\n<h2 id=\"how-to-create-a-python-virtual-environment-step-by-step\" class=\"wp-block-heading\">How to Create a Python Virtual Environment (Step-by-Step)<\/h2>\n\n\n\n<h3 id=\"step-1-open-terminal-in-your-project-folder\" class=\"wp-block-heading\">Step 1: Open Terminal in Your Project Folder<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new folder for your Django project (for example, <code>django-blog<\/code>), then open it in VS Code. Open the built-in terminal using <code>Ctrl+`<\/code> (Windows\/Linux) or <code>Cmd+J<\/code> (Mac).<\/p>\n\n\n\n<h3 id=\"step-2-create-the-virtual-environment-venv\" class=\"wp-block-heading\">Step 2: Create the Virtual Environment (venv)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python comes with a built-in module called <code>venv<\/code>, so you don&#8217;t need to install anything extra. Run this command inside your project folder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python -m venv env<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This creates a folder named <code>env<\/code> containing an isolated copy of Python and pip, separate from your system installation. You can name it anything, but <code>env<\/code> or <code>venv<\/code> are the most common conventions.<\/p>\n\n\n\n<h3 id=\"step-3-activate-the-virtual-environment\" class=\"wp-block-heading\">Step 3: Activate the Virtual Environment<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Activation tells your terminal to use the isolated Python inside <code>env<\/code> instead of your system Python.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Windows:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>env\\Scripts\\activate<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>macOS \/ Linux:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>source env\/bin\/activate<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once activated, you&#8217;ll see <code>(env)<\/code> appear at the start of your terminal line \u2014 that&#8217;s your confirmation it worked.<\/p>\n\n\n\n<h3 id=\"step-4-verify-and-install-packages-inside-venv\" class=\"wp-block-heading\">Step 4: Verify and Install Packages Inside venv<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the environment active, confirm you&#8217;re using the isolated Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip list<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see a short, clean list (just <code>pip<\/code> and <code>setuptools<\/code>) since nothing else has been installed yet. From here, any package you install with <code>pip install<\/code> \u2014 including Django in the next video \u2014 stays contained inside this project only.<\/p>\n\n\n\n<h2 id=\"common-errors-when-setting-up-a-python-virtual-environment\" class=\"wp-block-heading\">Common Errors When Setting Up a Python Virtual Environment<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&#8220;env is not recognized&#8221; on Windows<\/strong> \u2014 make sure you&#8217;re inside the correct project folder and using the exact activation command above.<\/li>\n\n\n\n<li><strong>Activation script blocked by PowerShell<\/strong> \u2014 run <code>Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned<\/code> once, then try activating again.<\/li>\n\n\n\n<li><strong>Forgetting to activate before installing packages<\/strong> \u2014 always check for <code>(env)<\/code> in your terminal prompt before running any <code>pip install<\/code> command.<\/li>\n\n\n\n<li><strong><code>python<\/code> command not found<\/strong> \u2014 revisit the previous lesson and confirm Python was added to PATH during installation.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"whats-next-in-the-django-course\" class=\"wp-block-heading\">What&#8217;s Next in the Django Course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With your Python virtual environment active and ready, you&#8217;re now set up to install Django itself in the next video and start your first project. Browse the full course roadmap on our <a href=\"https:\/\/nayananimsara.online\/course\/django-for-beginners-learn-python-web-development-from-scratch\/\" target=\"_blank\" rel=\"noreferrer noopener\">Django<\/a><a href=\"https:\/\/nimaacademy.lk\/django-course\/\" target=\"_blank\" rel=\"noopener\"> <\/a><a href=\"https:\/\/nayananimsara.online\/course\/django-for-beginners-learn-python-web-development-from-scratch\/\" target=\"_blank\" rel=\"noreferrer noopener\">course page<\/a> (replace with your actual course URL).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Official reference: <a href=\"https:\/\/docs.python.org\/3\/library\/venv.html\" target=\"_blank\" rel=\"noopener\">Python venv documentation<\/a><\/p>\n\n\n\n<h2 id=\"final-thoughts\" class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A Python virtual environment might feel like an extra step now, but it&#8217;s a habit every professional Django developer relies on. Get comfortable creating and activating <code>env<\/code> before every new project, and you&#8217;ll avoid dependency conflicts for good. See you in the next lesson!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"tg-oembed-container\"><iframe title=\"WebHD 720p 2\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/mG2zbqnFesA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Python Virtual Environment: 4 Simple Steps to Create venv for Django (2026) Welcome to video 3 of the Nima Academy Django course. Before installing Django itself, every professional Python developer sets up a Python virtual environment first. In this guide, you&#8217;ll learn exactly what venv is, why it matters, and how to create one in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1599,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"elearning_container_layout":"tg-site-layout--default","elearning_sidebar_layout":"tg-site-layout--default","elearning_remove_content_margin":false,"elearning_sidebar":"default","elearning_transparent_header":"customizer","elearning_logo":0,"elearning_header_style":"default","elearning_menu_item_color":"","elearning_menu_item_hover_color":"","elearning_menu_item_active_color":"","elearning_menu_item_active_style":"","elearning_page_header":true,"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1598","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django"],"_links":{"self":[{"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/posts\/1598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/comments?post=1598"}],"version-history":[{"count":1,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/posts\/1598\/revisions"}],"predecessor-version":[{"id":1600,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/posts\/1598\/revisions\/1600"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/media\/1599"}],"wp:attachment":[{"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/media?parent=1598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/categories?post=1598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayananimsara.online\/wp-json\/wp\/v2\/tags?post=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}