-
Notifications
You must be signed in to change notification settings - Fork 0
/
working-with-virtual-environment.html
183 lines (156 loc) · 8.51 KB
/
working-with-virtual-environment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!doctype html>
<html lang="en" itemscope itemtype="http://schema.org/Person">
<!-- <body background="https://images3.alphacoders.com/116/thumb-350-116875.jpg"> -->
<head>
<meta charset="utf-8">
<!-- Site Meta Data -->
<title>Working with Virtual Environment</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Snehal Karale">
<link rel="shortcut icon" href="">
<!-- schema.org -->
<meta itemprop="name" content="Snehal's Blog">
<meta itemprop="image" content="">
<meta itemprop="description" content="">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>
<!-- Style Meta Data -->
<link rel="stylesheet" href="/theme/css/style.css" type="text/css" />
<link rel="stylesheet" href="/theme/css/pygments.css" type="text/css" />
<!-- Feed Meta Data -->
<!-- Twitter Feed -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="">
<meta name="twitter:image" content="">
<meta name="twitter:creator" content="">
<meta name="twitter:url" content="/working-with-virtual-environment.html">
<meta name="twitter:title" content="Snehal's Blog ~ Working with Virtual Environment">
<meta name="twitter:description" content="<p>In the Last article, I shared how I started my internship at Red Hat and my first day
at Red Hat.
Now its time to share what I learnt from the second day. I will not explain day by day,
rather particular topic that I was not heard about. So ...</p>">
<!-- Facebook Meta Data -->
<meta property="og:title" content="Snehal's Blog ~ Working with Virtual Environment" />
<meta property="og:description" content="<p>In the Last article, I shared how I started my internship at Red Hat and my first day
at Red Hat.
Now its time to share what I learnt from the second day. I will not explain day by day,
rather particular topic that I was not heard about. So ...</p>" />
<meta property="og:image" content="" />
</head>
<body>
<!-- Sidebar -->
<aside>
<!-- <center><a href=""><img id="avatar" src=""></a></center> -->
<h1>Snehal's Blog</h1>
<br>
<nav class="nav">
<ul class="list-bare">
</ul>
</nav>
<p class="social">
<a href="https://www.facebook.com/snehal.karale.52" target="_blank" ><img src="/theme/images/icons/facebook.png"></a>
<a href="https://twitter.com/skarale25" target="_blank" ><img src="/theme/images/icons/twitter.png"></a>
<a href="https://in.linkedin.com/in/snehal-karale-09328251" target="_blank" ><img src="/theme/images/icons/linkedin.png"></a>
</p>
<h2>Categories</h2>
<ul class="navbar">
<li><a href="/category/experience-sharing.html">Experience Sharing</a></li>
<li class="active"><a href="/category/python.html">Python</a></li>
</ul>
</aside>
<!-- Content -->
<article>
<section id="content">
<article>
<h2 class="post_title post_detail"><a href="/working-with-virtual-environment.html" rel="bookmark" title="Permalink to Working with Virtual Environment">Working with Virtual Environment</a></h2>
<div class="entry-content blog-post">
<p>In the Last article, I shared how I started my internship at Red Hat and my first day
at Red Hat.
Now its time to share what I learnt from the second day. I will not explain day by day,
rather particular topic that I was not heard about. So today I will explain Virtual
Environments in Python.</p>
<p>As the name virtual environment, you will get the idea its an isolated python environment.
So why we need isolated environment? When you are working on different python projects,
you can keep dependencies required by different projects in separate places. Virtual
environment solves the issue that one project needs one version of software or module
and another project requires a newer version of same. When a virtual environment is created,
it creates a directory which contains all executables that project would need.</p>
<div class="section" id="how-to-use-virtual-environment">
<h2>How to use Virtual Environment</h2>
<p>'virtualenv' is used to create virtual environment. Before using virtualenv, you need to
check whether virtualenv is installed or not.
Following command is used to install 'virtualenv'</p>
<p>$ sudo dnf install python-virtualenv</p>
<p>or you can use</p>
<p>$ pip install virtualenv</p>
<p>Once you done installation, start using it :)</p>
<p>I will eplain you step by step process to use virtualenv</p>
<ol class="arabic">
<li><p class="first">Create your project directory and switch to it</p>
<blockquote>
<p>$ mkdir myproject</p>
<p>$ cd myproject/</p>
</blockquote>
</li>
<li><p class="first">Once you switch to project directory, do following</p>
<blockquote>
<p>$ virtualenv myenv</p>
<p>This will create directory named myenv in your myproject. You can check this by 'ls'</p>
</blockquote>
</li>
<li><p class="first">To activate Virtual Environment</p>
<blockquote>
<p>$ source myenv/bin/activate</p>
<p>when you execute this, you will see following on your terminal</p>
<blockquote>
<p>(myenv)[<a class="reference external" href="mailto:username@localhost">username@localhost</a> myproject]$</p>
</blockquote>
<p>Now you can start working on your project, you can install required packages that are
specific to this project.</p>
</blockquote>
</li>
<li><p class="first">To deactivate Virtual Environment</p>
<blockquote>
<p>$deactivate</p>
<p>Deactivating virtual environment brings you back in system's default python interpreter.</p>
</blockquote>
</li>
<li><p class="first">To delete Virtual Environment</p>
<blockquote>
<p>$ rm -rf myenv</p>
<p>Delete directory created by virtualenv</p>
</blockquote>
</li>
</ol>
<p>This is how you can keep two different projectes isolated.</p>
</div>
</div>
<div class="post_list">
<span>By </span>
<a href="/author/snehal-karale.html">@Snehal Karale</a>
<span> in </span>
<span class="post_category"><a href="/category/python.html" rel="bookmark" title="Permalink to Python">[ Python ]</a></span>
<span class="post_date">Fri 15 January 2016</span>
<div><span>Tags : </span>
</div>
<div class="entry-social">
<span class="twitter"><a target="_blank" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=700');return false;" title="Twitter" href="https://twitter.com/share?url=/working-with-virtual-environment.html&text=Working with Virtual Environment&via="><img src="/theme/images/icons/twitter-s.png"></a></span>
<span class="gplus"><a target="_blank" title="Google +" href="https://plus.google.com/share?url=/working-with-virtual-environment.html&hl=fr" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=650');return false;"><img src="/theme/images/icons/google-s.png"></a></span>
<span class="facebook"><a target="_blank" title="Facebook" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700');return false;" href="https://www.facebook.com/sharer.php?u=/working-with-virtual-environment.html&t=Working with Virtual Environment"><img src="/theme/images/icons/facebook-s.png"></a></span>
<a target="_blank" title="Linkedin" href="https://www.linkedin.com/shareArticle?mini=true&url=/working-with-virtual-environment.html&title=Working with Virtual Environment" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=650');return false;"><img src="/theme/images/icons/linkedin-s.png"></a>
<span class="mail"><a href="mailto:?subject=Working with Virtual Environment&body=Viens découvrir un article à propos de [Working with Virtual Environment] sur le site de Snehal Karale. /working-with-virtual-environment.html" title="Share by Email" target="_blank"><img src="/theme/images/icons/mail-s.png"></a></span>
</div>
</div>
</article>
</section>
</article>
<!-- Footer -->
<footer>
<p>
Blog powered by <a href="http://getpelican.com/">Pelican</a>,
which takes great advantage of <a href="http://python.org">Python</a>.
Theme <a href="https://github.com/parbhat/pelican-blue">Pelican-Blue</a> by <a href="https://parbhatpuri.com/">@parbhat</a>.
</p>
</footer>
</body>
</html>