parameters: (req)
docstring: Install python packages.
    Currently, the method simply calls ``python -m pip install`` but in the future further checks, optimizations,
    user confirmation may be implemented, therefore it is recommended over to use this method call instead of a plain
    pip install.
    :param req: requirement specifier, same format as used by pip (https://docs.python.org/3/installing/index.html)
  
    Example: calling from Slicer GUI
  
    .. code-block:: python
  
      pip_install("tensorflow keras scikit-learn ipywidgets")
  
    Example: calling from PythonSlicer console
  
    .. code-block:: python
  
      from slicer.util import pip_install
      pip_install("tensorflow")
docstring_summary: Install python packages.
    Currently, the method simply calls ``python -m pip install`` but in the future further checks, optimizations,
    user confirmation may be implemented, therefore it is recommended over to use this method call instead of a plain
    pip install.
    :param req: requirement specifier, same format as used by pip (https://docs.python.org/3/installing/index.html)
docstring_tokens: Install python packages . Currently the method simply calls python - m pip install but in the future further checks optimizations user confirmation may be implemented therefore it is recommended over to use this method call instead of a plain pip install . : param req : requirement specifier same format as used by pip ( https : // docs . python . org / 3 / installing / index . html )
function: def pip_install(req):
    """Install python packages.
    Currently, the method simply calls ``python -m pip install`` but in the future further checks, optimizations,
    user confirmation may be implemented, therefore it is recommended over to use this method call instead of a plain
    pip install.
    :param req: requirement specifier, same format as used by pip (https://docs.python.org/3/installing/index.html)
  
    Example: calling from Slicer GUI
  
    .. code-block:: python
  
      pip_install("tensorflow keras scikit-learn ipywidgets")
  
    Example: calling from PythonSlicer console
  
    .. code-block:: python
  
      from slicer.util import pip_install
      pip_install("tensorflow")
  
    """
  
    # Determine pythonSlicerExecutablePath
    try:
      from slicer import app
      # If we get to this line then import from "app" is succeeded,
      # which means that we run this function from Slicer Python interpreter.
      # PythonSlicer is added to PATH environment variable in Slicer
      # therefore shutil.which will be able to find it.
      import shutil
      import subprocess
      pythonSlicerExecutablePath = shutil.which('PythonSlicer')
      if not pythonSlicerExecutablePath:
        raise RuntimeError("PythonSlicer executable not found")
    except ImportError:
      # Running from console
      import os
      import sys
      pythonSlicerExecutablePath = os.path.dirname(sys.executable)+"/PythonSlicer"
      if os.name == 'nt':
        pythonSlicerExecutablePath += ".exe"
  
    command_line = [pythonSlicerExecutablePath, "-m", "pip", "install"]
    command_line.extend(req.split(" "))
    proc=launchConsoleProcess(command_line, useStartupEnvironment = False)
    logProcessOutput(proc)
function_tokens: def pip_install ( req ) : # Determine pythonSlicerExecutablePath try : from slicer import app # If we get to this line then import from "app" is succeeded, # which means that we run this function from Slicer Python interpreter. # PythonSlicer is added to PATH environment variable in Slicer # therefore shutil.which will be able to find it. import shutil import subprocess pythonSlicerExecutablePath = shutil . which ( 'PythonSlicer' ) if not pythonSlicerExecutablePath : raise RuntimeError ( "PythonSlicer executable not found" ) except ImportError : # Running from console import os import sys pythonSlicerExecutablePath = os . path . dirname ( sys . executable ) + "/PythonSlicer" if os . name == 'nt' : pythonSlicerExecutablePath += ".exe" command_line = [ pythonSlicerExecutablePath , "-m" , "pip" , "install" ] command_line . extend ( req . split ( " " ) ) proc = launchConsoleProcess ( command_line , useStartupEnvironment = False ) logProcessOutput ( proc )