{"id":37273,"date":"2024-11-01T09:56:14","date_gmt":"2024-11-01T09:56:14","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37273"},"modified":"2024-11-01T11:48:21","modified_gmt":"2024-11-01T11:48:21","slug":"python-virtual-environment-creating-a-venv-virtual-environment","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37273\/","title":{"rendered":"Python Virtual Environment, Creating a venv Virtual Environment"},"content":{"rendered":"<p><body><\/p>\n<article>\n<p>As you work with Python programming, you often engage in various projects, and during this process, there are many instances where different versions of packages or libraries are required for each project. To solve this problem, using a virtual environment is very useful. In this article, I will explain in detail how to create a virtual environment using Python&#8217;s basic virtual environment tool, <code>venv<\/code>, and how to utilize it.<\/p>\n<h2>What is a Virtual Environment?<\/h2>\n<p>A virtual environment refers to an independent Python environment that operates separately from the physical operating system. This allows for independent management of the packages required for a specific project, and it effectively manages dependencies across multiple projects without affecting the entire system.<\/p>\n<h2>Introduction to venv<\/h2>\n<p><code>venv<\/code> is a virtual environment creation tool included in the standard library starting from Python version 3.3. <code>venv<\/code> has the advantage of easily creating and using virtual environments with simple commands. Since it is a built-in module, there is no need for additional installation, and it can be used immediately without further configuration.<\/p>\n<h2>Creating a Virtual Environment with venv<\/h2>\n<h3>1. Check Python Installation<\/h3>\n<p>First, to use <code>venv<\/code>, Python must be installed. Open the terminal or command prompt and enter the following command to check if Python is installed:<\/p>\n<pre><code>python --version<\/code><\/pre>\n<p>Or if you are using a system that employs the <code>python3<\/code> command:<\/p>\n<pre><code>python3 --version<\/code><\/pre>\n<h3>2. Create a Virtual Environment<\/h3>\n<p>If the previously mentioned Python is installed, let&#8217;s create a virtual environment now. Enter the following command to create a virtual environment:<\/p>\n<pre><code>python -m venv myenv<\/code><\/pre>\n<p>Here, <code>myenv<\/code> is the name of the virtual environment, and you can change it to any name you prefer. Executing this command will create a folder named <code>myenv<\/code> in the current working directory, which will include the necessary files to set up the virtual environment.<\/p>\n<h3>3. Activate the Virtual Environment<\/h3>\n<p>After creating the virtual environment, you now need to activate it. Activating the virtual environment changes the terminal environment to the corresponding virtual environment, allowing only the packages within that path to be used.<\/p>\n<h4>Activation on Windows<\/h4>\n<pre><code>myenv\\Scripts\\activate<\/code><\/pre>\n<h4>Activation on macOS\/Linux<\/h4>\n<pre><code>source myenv\/bin\/activate<\/code><\/pre>\n<p>Once the virtual environment is activated, the name of the virtual environment will be displayed before the prompt. For example, it might appear as <code>(myenv)<\/code>. This indicates that the current virtual environment is active.<\/p>\n<h3>4. Install Packages<\/h3>\n<p>While the virtual environment is activated, you can install the necessary packages. For example, if you want to install a package called <code>requests<\/code>, you can enter the following command:<\/p>\n<pre><code>pip install requests<\/code><\/pre>\n<h3>5. Deactivate the Virtual Environment<\/h3>\n<p>After using the virtual environment, it&#8217;s necessary to deactivate it. To deactivate, enter the command below:<\/p>\n<pre><code>deactivate<\/code><\/pre>\n<p>Carefully entering the deactivate command will remove the name of the virtual environment from the prompt.<\/p>\n<h3>6. Delete the Virtual Environment<\/h3>\n<p>You can easily delete a virtual environment that you no longer need. While the virtual environment is deactivated, simply delete the directory where the virtual environment is located. For example, if you want to delete the virtual environment named <code>myenv<\/code>, you can type the following in the terminal:<\/p>\n<pre><code>rm -rf myenv<\/code><\/pre>\n<h2>Advantages of Virtual Environments<\/h2>\n<ul>\n<li><strong>Environment Independence:<\/strong> You can use different versions of packages for each project, preventing conflicts.<\/li>\n<li><strong>Ease of Development:<\/strong> By installing packages in a virtual environment, you can keep the terminal environment clean and free of unnecessary packages specific to particular projects.<\/li>\n<li><strong>Reproducibility:<\/strong> It is possible to set up the same package environment among team members and deployment environments, maintaining consistency between development and production environments.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this article, we explored how to create and utilize a virtual environment using Python&#8217;s <code>venv<\/code>. Virtual environments are essential tools for developers working on various projects in the field. They are highly effective for managing project dependencies and maintaining independent development environments. Now you can use <code>venv<\/code> to build a development environment optimized for your projects.<\/p>\n<p>I hope this will be of great help in your future Python learning and development!<\/p>\n<\/article>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you work with Python programming, you often engage in various projects, and during this process, there are many instances where different versions of packages or libraries are required for each project. To solve this problem, using a virtual environment is very useful. In this article, I will explain in detail how to create a &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37273\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Python Virtual Environment, Creating a venv Virtual Environment&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[98],"tags":[],"class_list":["post-37273","post","type-post","status-publish","format-standard","hentry","category--en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37273\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"As you work with Python programming, you often engage in various projects, and during this process, there are many instances where different versions of packages or libraries are required for each project. To solve this problem, using a virtual environment is very useful. In this article, I will explain in detail how to create a &hellip; \ub354 \ubcf4\uae30 &quot;Python Virtual Environment, Creating a venv Virtual Environment&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37273\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:56:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:48:21+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Python Virtual Environment, Creating a venv Virtual Environment\",\"datePublished\":\"2024-11-01T09:56:14+00:00\",\"dateModified\":\"2024-11-01T11:48:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/\"},\"wordCount\":628,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Python Study\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37273\/\",\"name\":\"Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:56:14+00:00\",\"dateModified\":\"2024-11-01T11:48:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37273\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37273\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Virtual Environment, Creating a venv Virtual Environment\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37273\/","og_locale":"ko_KR","og_type":"article","og_title":"Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"As you work with Python programming, you often engage in various projects, and during this process, there are many instances where different versions of packages or libraries are required for each project. To solve this problem, using a virtual environment is very useful. In this article, I will explain in detail how to create a &hellip; \ub354 \ubcf4\uae30 \"Python Virtual Environment, Creating a venv Virtual Environment\"","og_url":"https:\/\/atmokpo.com\/w\/37273\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:56:14+00:00","article_modified_time":"2024-11-01T11:48:21+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37273\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37273\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Python Virtual Environment, Creating a venv Virtual Environment","datePublished":"2024-11-01T09:56:14+00:00","dateModified":"2024-11-01T11:48:21+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37273\/"},"wordCount":628,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Python Study"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37273\/","url":"https:\/\/atmokpo.com\/w\/37273\/","name":"Python Virtual Environment, Creating a venv Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:56:14+00:00","dateModified":"2024-11-01T11:48:21+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37273\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37273\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37273\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Python Virtual Environment, Creating a venv Virtual Environment"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37273"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37273\/revisions"}],"predecessor-version":[{"id":37274,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37273\/revisions\/37274"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}