eric7.SystemUtilities.PythonUtilities

Module implementing Python related utility functions.

Global Attributes

None

Classes

None

Functions

__searchInterpreters_Linux Function to determine a list of all Python interpreters available via the executable search path (i.e.
__searchInterpreters_Windows Function to determine a list of all Python interpreters available via the executable search path (i.e.
_pipInstall Function to install the given packages via pip.
_uvInstall Function to install the given packages via uv.
determineVenvType Function to determine the type of the virtual environment.
findPyvenv Function to find the pyvenv.cfg file based on the used Python interpreter.
getExePath
getPythonExecutable Function to determine the path of the (non-windowed) Python executable.
getPythonInterpreterVersion Function to determine the exact version of a given Python interpreter.
getPythonLibPath Function to determine the path to Python's library.
getPythonLibraryDirectory Function to determine the path to Python's library directory.
getPythonScriptsDirectory Function to determine the path to Python's scripts directory.
getPythonVersion Function to get the Python version (major, minor) as an integer value.
installPackages Function to install the given packages.
isPythonSource Function to check for a Python source code file.
searchInterpreters Function to determine a list of all Python interpreters available via the executable search path (i.e.


__searchInterpreters_Linux

__searchInterpreters_Linux(environments=None)

Function to determine a list of all Python interpreters available via the executable search path (i.e. PATH) (non Windows variant).

environments (list of str (optional))
list of environment directories to scan for Python interpreters (defaults to None)
Return:
list of found interpreter executables
Return Type:
list of str
Up


__searchInterpreters_Windows

__searchInterpreters_Windows(environments=None)

Function to determine a list of all Python interpreters available via the executable search path (i.e. PATH) (Windows variant).

environments (list of str (optional))
list of environment directories to scan for Python interpreters (defaults to None)
Return:
list of found interpreter executables
Return Type:
list of str
Up


_pipInstall

_pipInstall(packages, interpreter="")

Function to install the given packages via pip.

packages (list of str)
list of packages to install
interpreter (str (optional))
interpreter to be used (defaults to "")
Up


_uvInstall

_uvInstall(packages, interpreter="")

Function to install the given packages via uv.

packages (list of str)
list of packages to install
interpreter (str (optional))
interpreter to be used (defaults to "")
Up


determineVenvType

determineVenvType(interpreter="")

Function to determine the type of the virtual environment.

interpreter (str (optional))
interpreter to be used (defaults to "")
Return:
type of the virtual environment ("uv", "uv seeded", "standard" or "")
Return Type:
str
Up


findPyvenv

findPyvenv(interpreter="")

Function to find the pyvenv.cfg file based on the used Python interpreter.

interpreter (str (optional))
interpreter to be used (defaults to "")
Return:
path of the 'pyvenv.cfg' file or an empty string, if it was not found or the Python interpreter does not belong to a virtual environment
Return Type:
str
Up


getExePath

getExePath(branch, access, versionStr)
Up


getPythonExecutable

getPythonExecutable()

Function to determine the path of the (non-windowed) Python executable.

Return:
path of the Python executable
Return Type:
str
Up


getPythonInterpreterVersion

getPythonInterpreterVersion(interpreter)

Function to determine the exact version of a given Python interpreter.

interpreter (str)
path of the Python interpreter binary
Return:
version of the Python interpreter
Return Type:
str
Up


getPythonLibPath

getPythonLibPath()

Function to determine the path to Python's library.

Return:
path to the Python library
Return Type:
str
Up


getPythonLibraryDirectory

getPythonLibraryDirectory()

Function to determine the path to Python's library directory.

Return:
path to the Python library directory
Return Type:
str
Up


getPythonScriptsDirectory

getPythonScriptsDirectory()

Function to determine the path to Python's scripts directory.

Return:
path to the Python scripts directory
Return Type:
str
Up


getPythonVersion

getPythonVersion()

Function to get the Python version (major, minor) as an integer value.

Return:
integer representing major and minor version number
Return Type:
int
Up


installPackages

installPackages(packages, interpreter="")

Function to install the given packages.

packages (list of str)
list of packages to install
interpreter (str (optional))
interpreter to be used (defaults to "")
Up


isPythonSource

isPythonSource(filename, source, editor=None)

Function to check for a Python source code file.

filename (str)
name of the file with extension
source (str)
of the file
editor (Editor (optional))
reference to the editor, if the file is opened already (defaults to None)
Return:
flag indicating Python source code
Return Type:
bool
Up


searchInterpreters

searchInterpreters(environments=None)

Function to determine a list of all Python interpreters available via the executable search path (i.e. PATH) (Windows variant).

environments (list of str (optional))
list of environment directories to scan for Python interpreters (defaults to None)
Return:
list of found interpreter executables
Return Type:
list of str
Up