Skip to content
Myr

Separate out virtualenv docs to its own sections (#2551)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rowlando13 · committed by GitHub · parents 8fa833e, cb145c3 · Browse files · 3 files+59 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+59 added−57 removed

  • other:+59 added−57 removed

3 files+59 added−57 removed

modified:docs/index.rst+1 added
66 unmodified lines
67 :maxdepth: 26869 why70 quickstart71 virtualenv72 setuptools73 parameters74 options75 arguments
33 unmodified lines
modified:docs/quickstart.rst+4 added-57 removed
1 unmodified line
2==========34.. currentmodule:: click56You can get the library directly from PyPI::6Install7----------------------8Install from PyPI::910 pip install click1110The installation into a :ref:`virtualenv` is heavily recommended.12Installing into a virtual environment is highly recommended. We suggest :ref:`virtualenv-heading`.1312.. _virtualenv:1314virtualenv15----------1617Virtualenv is probably what you want to use for developing Click18applications.1920What problem does virtualenv solve? Chances are that you want to use it21for other projects besides your Click script. But the more projects you22have, the more likely it is that you will be working with different23versions of Python itself, or at least different versions of Python24libraries. Let's face it: quite often libraries break backwards25compatibility, and it's unlikely that any serious application will have26zero dependencies. So what do you do if two or more of your projects have27conflicting dependencies?2829Virtualenv to the rescue! Virtualenv enables multiple side-by-side30installations of Python, one for each project. It doesn't actually31install separate copies of Python, but it does provide a clever way to32keep different project environments isolated.3334Create your project folder, then a virtualenv within it::3536 $ mkdir myproject37 $ cd myproject38 $ python3 -m venv .venv3940Now, whenever you want to work on a project, you only have to activate the41corresponding environment. On OS X and Linux, do the following::4243 $ . .venv/bin/activate44 (venv) $4546If you are a Windows user, the following command is for you::4748 > .venv\scripts\activate49 (venv) >5051Either way, you should now be using your virtualenv (notice how the prompt of52your shell has changed to show the active environment).5354And if you want to stop using the virtualenv, use the following command::5556 $ deactivate5758After doing this, the prompt of your shell should be as familiar as before.5960Now, let's move on. Enter the following command to get Click activated in your61virtualenv::6263 $ pip install click6465A few seconds later and you are good to go.6614Screencast and Examples15-----------------------1617There is a screencast available which shows the basic API of Click and
210 unmodified lines
added:docs/virtualenv.rst+54 added
1.. _virtualenv-heading:23Virtualenv4=========================56Why Use Virtualenv?7-------------------------89You should use `Virtualenv <https://virtualenv.pypa.io/en/latest/>`_ because:1011* It allows you to install multiple versions of the same dependency.1213* If you have an operating system version of Python, it prevents you from changing its dependencies and potentially messing up your os.1415How to Use Virtualenv16-----------------------------1718Create your project folder, then a virtualenv within it::1920 $ mkdir myproject21 $ cd myproject22 $ python3 -m venv .venv2324Now, whenever you want to work on a project, you only have to activate the25corresponding environment.2627.. tabs::2829 .. group-tab:: OSX/Linux3031 .. code-block:: text3233 $ . .venv/bin/activate34 (venv) $3536 .. group-tab:: Windows3738 .. code-block:: text3940 > .venv\scripts\activate41 (venv) >424344You are now using your virtualenv (notice how the prompt of your shell has changed to show the active environment).4546To install packages in the virtual environment::4748 $ pip install click4950And if you want to stop using the virtualenv, use the following command::5152 $ deactivate5354After doing this, the prompt of your shell should be as familiar as before.