Managing Packages with pip

pip is Python’s package installer. It allows you to install and manage libraries or other dependencies that are not part of the Python standard library. In CukeTest’s built-in Python environment, pip is preinstalled as well, enabling you to install, update, and remove Python packages easily.

Basic Usage

  1. Launch CukeTest.
  2. Navigate to the Tools menu and select Command Line Tool or Terminal (depending on your version of CukeTest).
  3. In the launched command-line tool, you can execute the following commands to manage Python packages:

    • Windows:Use the pip command directly.
    • Linux:Use the python3 -m pip command.

Installing a New Python Package

To install a new Python package in CukeTest’s Python environment, run the following command:

pip install package_name

Replace package_name with the name of the package you want to install.

Installing a Specific Version

If you need to install a specific version of a Python package, use the command with the following format:

pip install package_name==version_number

Here, the version_number is the version you need. For example, to install NumPy version 1.18.5, run the following command:

pip install numpy==1.18.5

This approach helps you control the library versions used in your project, avoiding incompatibility issues, especially when your project depends on specific features or APIs.

Updating Installed Packages

Keeping your Python packages up to date is essential for ensuring compatibility and security. To update an already installed package, run the following command:

pip install --upgrade package_name

Uninstalling Packages

If you need to remove an unused package from CukeTest’s Python environment, run the following command:

pip uninstall package_name

Listing Installed Packages

To view all installed packages and their corresponding versions, run the following command:

pip list

This is particularly helpful when troubleshooting dependency issues.

Best Practices for Package Management

  • Check and update dependencies regularly: In order to benefit from the latest bug fixes and security patches.
  • Understand the purpose of each package: In order to avoid unnecessary clutter and keep the environment efficient.
  • Use virtual environments:If possible, different projects should maintain separate dependency environments to prevent version conflicts.

Summary

By following these steps, you can effectively manage third-party Python packages within CukeTest, ensuring your test projects run smoothly while leveraging the vast resources of the Python ecosystem.