Skip to content

Commit 5596bc8

Browse files
authored
john-science#53 flushing out examples
1 parent 6b36665 commit 5596bc8

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

classes/22_virtualenv/lecture_22.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,38 @@ Okay! Now we have a Virtual Environment with all our packages installed, and we
5757
5858
## Example 2 - A Web Developer's Env
5959

60-
> TODO: python2.7
60+
Okay, for our second example say you are looking at the code for a little web app a colleague is making. For some reason, she uses Python 2.7, not the 3.6 your data scientist uses or even the 3.7 you use. And she uses an older version of NumPy , and installs Django (for making websites). Again, you don't want to wreck your own code, and now you don't want to wreck your data scientist area either.
61+
62+
VirtualEnv to the rescue!
63+
64+
First, let's make a directory to drop her code into:
65+
66+
mkdir web_work
67+
cd web_work
68+
69+
Now let's create a VirtualEnv to mimic her environment:
70+
71+
virtualenv --python=python3.6 web_env
72+
73+
Now we can start using that environment:
74+
75+
source web_env/bin/activate
76+
77+
Okay, now through this text into a file called `requirements.txt`:
6178

6279
dango==1.11.20
63-
numpy==1.15.0
80+
numpy == 1.15.0
81+
82+
Now run this `pip` command (this is a standard way to install third-party libraries in Python and is not specific to VirtualEnv):
83+
84+
pip install -r requirements.txt
85+
86+
Okay! Now we have a Virtual Environment with all our packages installed, and we can use it:
87+
88+
$ python
89+
90+
> TODO: python
91+
6492

6593
## Clean Up
6694

0 commit comments

Comments
 (0)