Virtual environments and considerations

IBM® Open Enterprise SDK for Python provides the venv module for creating lightweight virtual environments. This module allows you to manage separate package installations for different projects. To create a virtual environment, run the venv module as a script with the directory path as the following command:
python3 -m venv  /path/to/new/virtual/environment
The previous command creates a target directory and a bin subdirectory that contains a copy of the Python binaries files and link to standard libraries. If you want to pull all packages bundled with IBM Open Enterprise SDK for Python into the virtual environments, run the above command with --system-site-packages option:
python3 -m venv  /path/to/new/virtual/environment --system-site-packages
The previous command creates the virtual environments that contain all the IBM Open Enterprise SDK for Python bundled packages such as: cffi, cryptography, and so on.

IBM Open Enterprise SDK for Python contains rebuilt PyPI packages. By default, creating a virtual environment creates a clean environment, which means no packages installed. Specifying the --system-site-packages flag exposes these additional packages contained within IBM Open Enterprise SDK for Python, so that they can be used within your virtual environment. This action is required if you need to install a package that has dependencies on one of these bundled packages. Otherwise, pip installs packages from PyPI which can lead to installation failure.

Once you create a virtual environment, you can activate it by running the following line:
. </path/to/new/virtual/environment/>/bin/activate

For more information about installing packaging by using pip and virtual environments, see Installing packages using pip and virtual environments and venv — Creation of virtual environments in the official Python documentation.