Skip to content

Instantly share code, notes, and snippets.

@NdagiStanley NdagiStanley/.md
Last active Aug 4, 2019

What would you like to do?


  • Usage:

    To skip file enter this comment in that file, preferably at the top.

    # flake8: noqa

    To not issue warnings, add the following comment at the end of the file.

    # noqa
    # or
    # noqa: <error-token>
    # or
    # noqa: <error-token>, <error-token>...
  • VS Code

    "python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Args": [


  • Usage:
    import pysnooper

Installing packages

There are differences in installing packages in the two versions of Python

For python version 2:

python -m pip install pyfirebase

or if you updated the shell command:

python2 -m pip install pyfirebase

For python version 3:

pip install pyfirebase

Different versions of Python

Using pyenv

brew install pyenv
pyenv install <version>. For the full list, run pyenv install --list

Always use virtual environments


For a specific directory set python version: pyenv local <version>
mkvirtualenv --python=$(pyenv which python) <env name>

Then use workon (that comes with virtualenv-wrapper)

python2 and python3 shall be used to specify Python version 2 and Python version 3 respectively.

Download & install

Download from the Python website and install.

Add to Path

  • Click on Add to Path in the installation windows, otherwise:

  • Navigate to My Computer (System)/ Properties/ Advanced Settings/ Environment Variables and add c:\Python27\ (for Python2) and/or c:\Python36\ (for Python3)

Update shell command to call python

If you are one version of Python skip this part. Otherwise, I would advise to update the less used python version as described below:


  • Navigate to the Python27 folder in C:\ and change python.exe to python2.exe.
  • Navigate to the Python32-36 (or otherwise) folder in C:\ and change python.exe to python3.exe

PIP (package installer for Python)

Python3 comes with pip installed.

Install pip in python2


or if you updated the shell command:


Installing packages

Virtual Environments in Windows

Virtual environments

More details are here featuring the three main ways to create and use virtual environments in Python:

  • pipenv
  • virtualenv
  • virtualenv-wrapper

and bonus:

  • venv (Avaliable in python 3.3+)


# First install pipenv package:
<pip install pipenv>

cd project_folder
pipenv install <package>
pipenv run <script>
pipenv shell  # Shell (Anthing run after this is done within the environment)

venv (Avaliable in python 3.3+)

python3 -m venv /path/to/new/virtual/environment


# First install virtualenv package:
<pip install virtualenv>

cd project_folder

# Create environment
virtualenv <environment-name>
# or
virtualenv </path/to/new/virtual/environment>

# Specify python version for the environment
virtualenv -p <python-version shell-command> <environment-name>
# or
virtualenv -p <python-version shell-command> </path/to/new/virtual/environment>

# Activate environment
source <environment-name>/bin/activate
# or
source </path/to/new/virtual/environment>/bin/activate

<pip install package>


# First install virtualenvwrapper package:
<pip install virtualenvwrapper>

export WORKON_HOME=~/Envs

source /usr/local/bin/
# or
source <path/to/>

mkvirtualenv <environment-name>
workon <environment-name>
workon <previously-created-environment-name>
mkvirtualenv <previously-created-environment-name>


For Windows the package is virtualenvwrapper-win and WORKON_HOME is %USERPROFILE%\Envs by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.