Python: virtualenv Tutorial

By Xah Lee. Date: . Last updated: .

virtualenv is a tool to create isolated Python environments, so you can install different version of python and different versions of library.

◆ virtualenv
You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR

  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         Increase verbosity.
  -q, --quiet           Decrease verbosity.
  -p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g., --python=python2.5 will use the
                        python2.5 interpreter to create the new environment.  The default is the
                        interpreter that virtualenv was installed with (/usr/bin/python)
  --clear               Clear out the non-root install and start from scratch.
  --no-site-packages    DEPRECATED. Retained only for backward compatibility. Not having access to
                        global site-packages is now the default behavior.
                        Give the virtual environment access to the global site-packages.
  --always-copy         Always copy files rather than symlinking.
  --unzip-setuptools    Unzip Setuptools when installing it.
  --relocatable         Make an EXISTING virtualenv environment relocatable. This fixes up scripts
                        and makes all .pth files relative.
  --no-setuptools       Do not install setuptools (or pip) in the new virtualenv.
  --no-pip              Do not install pip in the new virtualenv.
                        Directory to look for setuptools/pip distributions in. This option can be
                        used multiple times.
  --never-download      DEPRECATED. Retained only for backward compatibility. This option has no
                        effect. Virtualenv never downloads pip or setuptools.
  --prompt=PROMPT       Provides an alternative prompt prefix for this environment.
  --setuptools          DEPRECATED. Retained only for backward compatibility. This option has no
  --distribute          DEPRECATED. Retained only for backward compatibility. This option has no

see also Python: What's PyPi, pip, easy_install, setuptools?

If you have a question, put $5 at patreon and message me.


  1. Python 3 Basics
  2. Python 2 Basics
  3. Python 2 and 3 Difference
  4. Print Version
  5. Builtin Help
  6. Quote String
  7. String Methods
  8. Format String
  9. Operators
  10. Complex Numbers
  11. True, False
  12. if then else
  13. Loop
  14. List Basics
  15. Loop Thru List
  16. Map f to List
  17. Copy Nested List
  18. List Comprehension
  19. List Methods
  20. Sort
  21. Dictionary
  22. Loop Thru Dict
  23. Dict Methods
  24. Tuple
  25. Sets
  26. Function
  27. Closure
  28. 2 Closure
  29. Decorator
  30. Class
  31. Object, ID, Type
  32. List Modules
  33. Write a Module
  34. Unicode 🐍


  1. Regex Basics
  2. Regex Reference

Text Processing

  1. Read/Write File
  2. Traverse Directory
  3. File Path
  4. Process Unicode
  5. Convert File Encoding
  6. Find Replace in dir
  7. Find Replace by Regex
  8. Count Word Frequency


  1. Send Email
  2. GET Web Page
  3. Web Crawler


  1. JSON
  2. Find Script Path
  3. Get Env Var
  4. System Call
  5. Decompress Gzip
  6. Append String in Loop
  7. Timing f timeit
  8. Keyword Arg Default Value Unstable
  9. Check Page Load Size
  10. Thumbnail Generation