{"id":37267,"date":"2024-11-01T09:56:12","date_gmt":"2024-11-01T09:56:12","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37267"},"modified":"2024-11-01T14:46:17","modified_gmt":"2024-11-01T14:46:17","slug":"divpython-virtual-environment-creating-anaconda-virtual-environment","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37267\/","title":{"rendered":"Python Virtual Environment, Creating Anaconda Virtual Environment"},"content":{"rendered":"<p><body><\/p>\n<article>\n<header>\n<p>Python is a powerful programming language that is useful in various projects. However, it is important to create a virtual environment, as libraries and packages used in different projects can easily collide. In this blog post, we will explore how to create a virtual environment using Python and Anaconda.<\/p>\n<\/header>\n<section>\n<h2>1. What is a virtual environment?<\/h2>\n<p>A virtual environment provides an independent Python environment for each project, preventing version conflicts of libraries and packages needed for different projects. It is useful when working on multiple projects simultaneously and helps ensure code reproducibility and manage dependencies effectively.<\/p>\n<p>Using a virtual environment offers the following benefits:<\/p>\n<ul>\n<li>You can maintain package versions independently across projects.<\/li>\n<li>You can run them separately from libraries installed on the system, keeping the system environment clean.<\/li>\n<li>You can create the same environment as your teammates, increasing the portability of your code.<\/li>\n<\/ul>\n<\/section>\n<section>\n<h2>2. Creating a virtual environment<\/h2>\n<p>There are several ways to create a virtual environment, and the most common method is to use Python&#8217;s built-in module, <code>venv<\/code>. Here\u2019s how to create a virtual environment using <code>venv<\/code>.<\/p>\n<h3>2.1. Creating a virtual environment with venv<\/h3>\n<p>First, open the command line or terminal and enter the following:<\/p>\n<p><code>python -m venv myenv<\/code><\/p>\n<p>In the above command, <code>myenv<\/code> is the name of the virtual environment. You can change it to any name you want. Running this command will create a folder named <code>myenv<\/code> in the current directory, which will contain the Python executable and a <code>site-packages<\/code> directory.<\/p>\n<h3>2.2. Activating the virtual environment<\/h3>\n<p>After creating a virtual environment, you need to activate it. The activation method varies by operating system.<\/p>\n<ul>\n<li>Windows:<\/li>\n<p><code>myenv\\Scripts\\activate<\/code><\/p>\n<li>macOS\/Linux:<\/li>\n<p><code>source myenv\/bin\/activate<\/code>\n<\/ul>\n<p>Once the virtual environment is activated, the name of the virtual environment will be displayed before the command prompt.<\/p>\n<h3>2.3. Installing packages<\/h3>\n<p>While the virtual environment is activated, you can install the required packages. For example, to install the <code>requests<\/code> package, enter the following:<\/p>\n<p><code>pip install requests<\/code><\/p>\n<p>This will install the <code>requests<\/code> package within the virtual environment.<\/p>\n<h3>2.4. Deactivating the virtual environment<\/h3>\n<p>After finishing your work, you should deactivate the virtual environment. You can do so with the following command.<\/p>\n<p><code>deactivate<\/code><br \/>\n<\/section>\n<section>\n<h2>3. Creating a virtual environment using Anaconda<\/h2>\n<p>Anaconda is a Python distribution specialized for data science and machine learning, providing a very useful tool for package management and environment management called <code>conda<\/code>. With <code>conda<\/code>, you can easily create and manage virtual environments.<\/p>\n<h3>3.1. Installing Anaconda<\/h3>\n<p>To use Anaconda, you first need to install it. Anaconda can be downloaded from the official website (<a href=\"https:\/\/www.anaconda.com\/products\/distribution#download-section\">Anaconda Homepage<\/a>). After installation, you can create a virtual environment using the <code>conda<\/code> command in the command line.<\/p>\n<h3>3.2. Creating a virtual environment<\/h3>\n<p>You can create a new virtual environment by entering the following command:<\/p>\n<p><code>conda create -n myenv python=3.8<\/code><\/p>\n<p>Here, the <code>-n<\/code> option specifies the name of the virtual environment, and <code>python=3.8<\/code> specifies the Python version to use. After the environment is created, the following message will be displayed:<\/p>\n<p><em>Proceed ([y]\/n)?<\/em><\/p>\n<p>At this point, entering <code>y<\/code> will install the necessary packages.<\/p>\n<h3>3.3. Activating the virtual environment<\/h3>\n<p>To activate the created virtual environment, use the following command:<\/p>\n<p><code>conda activate myenv<\/code><\/p>\n<p>When the virtual environment is activated, the command prompt will change to indicate the activated environment.<\/p>\n<h3>3.4. Installing packages<\/h3>\n<p>To install the required packages while the virtual environment is activated, enter the following:<\/p>\n<p><code>conda install requests<\/code><\/p>\n<p>The above command installs the <code>requests<\/code> package. You can also use <code>pip<\/code>, but it is preferable to install packages through <code>conda<\/code>.<\/p>\n<h3>3.5. Deactivating the virtual environment<\/h3>\n<p>To deactivate the virtual environment, enter the following command:<\/p>\n<p><code>conda deactivate<\/code><br \/>\n<\/section>\n<section>\n<h2>4. Managing virtual environments<\/h2>\n<p>In addition to creating and using virtual environments, it is also important to manage the created virtual environments. Anaconda makes this management easier.<\/p>\n<h3>4.1. Checking the list of created virtual environments<\/h3>\n<p>To see a list of all virtual environments created on the current system, use the following command:<\/p>\n<p><code>conda info --envs<\/code><\/p>\n<p>or<\/p>\n<p><code>conda env list<\/code><\/p>\n<p>This command will display all the virtual environments on the system along with their paths.<\/p>\n<h3>4.2. Deleting a virtual environment<\/h3>\n<p>If a virtual environment is no longer needed, it can be deleted. Enter the following command to delete a virtual environment:<\/p>\n<p><code>conda remove -n myenv --all<\/code><\/p>\n<p>Here, <code>myenv<\/code> is the name of the virtual environment to be deleted.<\/p>\n<h3>4.3. Exporting and Importing<\/h3>\n<p>You can export the settings of a virtual environment to an <code>environment.yml<\/code> file or import the same settings to another environment.<\/p>\n<p>To export the virtual environment:<\/p>\n<p><code>conda env export &gt; environment.yml<\/code><\/p>\n<p>To import this environment on another system:<\/p>\n<p><code>conda env create -f environment.yml<\/code><br \/>\n<\/section>\n<section>\n<h2>5. Conclusion<\/h2>\n<p>A virtual environment is a very useful tool for managing multiple projects.<\/p>\n<p>You can easily create and manage virtual environments using Python&#8217;s <code>venv<\/code> module or Anaconda&#8217;s <code>conda<\/code> command. This greatly helps in managing reproducibility and dependencies for projects.<\/p>\n<p>Now, I hope you can utilize virtual environments to create a more effective Python development environment! If you have any questions, feel free to ask in the comments.<\/p>\n<\/section>\n<\/article>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python is a powerful programming language that is useful in various projects. However, it is important to create a virtual environment, as libraries and packages used in different projects can easily collide. In this blog post, we will explore how to create a virtual environment using Python and Anaconda. 1. What is a virtual environment? &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37267\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Python Virtual Environment, Creating Anaconda 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-37267","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 Anaconda 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\/37267\/\" \/>\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 Anaconda Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Python is a powerful programming language that is useful in various projects. However, it is important to create a virtual environment, as libraries and packages used in different projects can easily collide. In this blog post, we will explore how to create a virtual environment using Python and Anaconda. 1. What is a virtual environment? &hellip; \ub354 \ubcf4\uae30 &quot;Python Virtual Environment, Creating Anaconda Virtual Environment&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37267\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:56:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T14:46:17+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=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Python Virtual Environment, Creating Anaconda Virtual Environment\",\"datePublished\":\"2024-11-01T09:56:12+00:00\",\"dateModified\":\"2024-11-01T14:46:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/\"},\"wordCount\":749,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Python Study\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37267\/\",\"name\":\"Python Virtual Environment, Creating Anaconda Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:56:12+00:00\",\"dateModified\":\"2024-11-01T14:46:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37267\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37267\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Virtual Environment, Creating Anaconda 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 Anaconda 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\/37267\/","og_locale":"ko_KR","og_type":"article","og_title":"Python Virtual Environment, Creating Anaconda Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Python is a powerful programming language that is useful in various projects. However, it is important to create a virtual environment, as libraries and packages used in different projects can easily collide. In this blog post, we will explore how to create a virtual environment using Python and Anaconda. 1. What is a virtual environment? &hellip; \ub354 \ubcf4\uae30 \"Python Virtual Environment, Creating Anaconda Virtual Environment\"","og_url":"https:\/\/atmokpo.com\/w\/37267\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:56:12+00:00","article_modified_time":"2024-11-01T14:46:17+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":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37267\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37267\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Python Virtual Environment, Creating Anaconda Virtual Environment","datePublished":"2024-11-01T09:56:12+00:00","dateModified":"2024-11-01T14:46:17+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37267\/"},"wordCount":749,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Python Study"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37267\/","url":"https:\/\/atmokpo.com\/w\/37267\/","name":"Python Virtual Environment, Creating Anaconda Virtual Environment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:56:12+00:00","dateModified":"2024-11-01T14:46:17+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37267\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37267\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37267\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Python Virtual Environment, Creating Anaconda 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\/37267","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=37267"}],"version-history":[{"count":2,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37267\/revisions"}],"predecessor-version":[{"id":38148,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37267\/revisions\/38148"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}