17. Installing Packages

17.1. Virtualenv

  • What is Virtualenv
  • Directories
venv/
.venv/

virtualenv/
.virtualenv/

.virtualenv-3.6/
.virtualenv-3.7/

venv-3.6/
venv-3.7/

.venv-3.6/
.venv-3.7/

~/.virtualenv/.../

17.2. Searching

17.3. Installing

  • pip install ...
  • requirements.txt
  • pip install -r requirements.txt

17.4. Using

import ...

17.5. Importing

import sys

sys.path
sys.path.append
sys.path.insert(0, '/path/to/directory')
game
    __init__.py
    config.py
    api.py
    dragon
        __init__.py
        wawelski.py
        red.py
        black.py
        white.py
from game.config import RESOLUTION_MAX_X
from game.dragon import red
from game.dragon import white


my_dragon1 = red.RedDragon()
my_dragon2 = white.WhiteDragon()
from game.dragon import *

my_dragon1 = red.RedDragon()
my_dragon2 = white.WhiteDragon()
from game.dragon.red import RedDragon
from game.dragon.white import WhiteDragon

my_dragon1 = RedDragon()
my_dragon2 = WhiteDragon()
from game.dragon.red import RedDragon as Smok

wawelski = Smok()

17.6. Assignments

17.6.1. Virtualenv

  1. Stwórz virtualenv z instalacją Python
  2. Dodaj virtualenv do Python Interpreter w Twoim IDE

17.6.2. Installing from requirements.txt

  1. Stwórz plik requirements.txt
  2. Dopisz linijkę pycodestyle do requirements.txt
  3. Niech Twoje IDE zainstaluje bibliotekę automatycznie (kliknięcie w żółty banner)
About:
  • Filename: requirements.txt
  • Lines of code to write: 1 line
  • Estimated time of completion: 5 min