activate a venv python code example

Example 1: python virtual environment

python3 -m venv env
python -m virtualenv env #py2

source env/bin/activate

#all this is on same directory

Example 2: python virtual environment

source env/bin/activate

Example 3: activate venv

venv\Scripts\activate.bat

Example 4: activate venv in python

(tutorial-env) $ python -m pip install --upgrade requests
Collecting requests
Installing collected packages: requests
  Found existing installation: requests 2.6.0
    Uninstalling requests-2.6.0:
      Successfully uninstalled requests-2.6.0
Successfully installed requests-2.7.0

Example 5: activate venv in python

(tutorial-env) $ pip search astronomy
skyfield               - Elegant astronomy for Python
gary                   - Galactic astronomy and gravitational dynamics.
novas                  - The United States Naval Observatory NOVAS astronomy library
astroobs               - Provides astronomy ephemeris to plan telescope observations
PyAstronomy            - A collection of astronomy related tools for Python.
...