Django for Designers/Laptop setup/Windows virtualenv: Difference between revisions

From OpenHatch wiki
imported>Paulproteus
imported>Paulproteus
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
Take this moment to open up a command prompt. Enter the command:
 
Take this moment to open up a command prompt. Enter the command:
   
<code>
+
<pre>
 
virtualenv --help
 
virtualenv --help
</code>
+
</pre>
   
 
You should see a help message that looks something like this:
 
You should see a help message that looks something like this:
Line 18: Line 18:
 
</pre>
 
</pre>
   
If you don't see that friendly message, grab [https://raw.github.com/pypa/virtualenv/master/virtualenv.py virtualenv.py] and save it ... where?
+
If you don't see that friendly message, download ''virtualenv.py'' from here:
  +
  +
* [https://raw.github.com/pypa/virtualenv/master/virtualenv.py virtualenv.py]
  +
  +
and save it inside the ''django-for-designers'' folder.
  +
  +
== Navigate to the django-for-designers folder ==
  +
  +
Open a command prompt, and use the ''cd'' command to find the ''django-for-designers'' folder.
  +
  +
You can use the ''dir'' command to list the folder. Run this command:
  +
  +
<pre>dir</pre>
  +
  +
and make sure you see a requirements.txt file.
  +
  +
== Create a virtualenv ==
  +
  +
A virtualenv is a limited Python environment that permits you to install whatever Python code you like without impacting other Python programs.
  +
  +
First, we will have to create the virtualenv. In your command prompt, type this command. The '''.''' at the end does matter, so be sure to type it!
  +
  +
<pre>
  +
virtualenv .
  +
</pre>
  +
  +
If you get a ''command not found'' error, type this instead:
  +
  +
<pre>
  +
python virtualenv.py .
  +
</pre>
  +
  +
Eventually you will get your prompt back.
  +
  +
== Activate the virtualenv ==
  +
  +
When you ''activate'' a virtualenv, it gives you access to the Python code within the virtualenv. (By contrast, your system Python does not have access to the code within the virtualenv.)
  +
  +
Run this command:
  +
  +
<pre>
  +
Scripts\activate
  +
</pre>
  +
  +
You should see your command prompt change to say ''django-for-designers''; that is how you know you have it activated.
  +
  +
== Install the requirements ==
  +
  +
You need to use the ''pip'' package manager within your virtualenv to install all the code required to have a successful tutorial. To do that, first make sure your command prompt has the virtualenv activated.
  +
  +
Then run:
  +
  +
<pre>
  +
pip install -r requirements.txt
  +
</pre>
  +
  +
This will run for a few minutes, downloading code. Eventually, you will get your prompt back. Success!
  +
  +
== Return to laptop setup ==
  +
  +
&laquo; [[../|Return to laptop setup]]

Latest revision as of 05:39, 11 March 2013

Test if you have the required tools

In this step, we test if you have the virtualenv tool.

Take this moment to open up a command prompt. Enter the command:

virtualenv --help

You should see a help message that looks something like this:

Usage: virtualenv [OPTIONS] DEST_DIR

Options:
  --version             show program's version number and exit

If you don't see that friendly message, download virtualenv.py from here:

and save it inside the django-for-designers folder.

Navigate to the django-for-designers folder

Open a command prompt, and use the cd command to find the django-for-designers folder.

You can use the dir command to list the folder. Run this command:

dir

and make sure you see a requirements.txt file.

Create a virtualenv

A virtualenv is a limited Python environment that permits you to install whatever Python code you like without impacting other Python programs.

First, we will have to create the virtualenv. In your command prompt, type this command. The . at the end does matter, so be sure to type it!

virtualenv .

If you get a command not found error, type this instead:

python virtualenv.py .

Eventually you will get your prompt back.

Activate the virtualenv

When you activate a virtualenv, it gives you access to the Python code within the virtualenv. (By contrast, your system Python does not have access to the code within the virtualenv.)

Run this command:

Scripts\activate

You should see your command prompt change to say django-for-designers; that is how you know you have it activated.

Install the requirements

You need to use the pip package manager within your virtualenv to install all the code required to have a successful tutorial. To do that, first make sure your command prompt has the virtualenv activated.

Then run:

pip install -r requirements.txt

This will run for a few minutes, downloading code. Eventually, you will get your prompt back. Success!

Return to laptop setup

« Return to laptop setup