pythonfinder.pythonfinder module

class pythonfinder.pythonfinder.Finder(path=None, system=False, global_search=True, ignore_unsupported=True, sort_by_path=False)[source]

Bases: object

A cross-platform Finder for locating python and other executables.

Searches for python and other specified binaries starting in path, if supplied, but searching the bin path of sys.executable if system is True, and then searching in the os.environ['PATH'] if global_search is True. When global_search is False, this search operation is restricted to the allowed locations of path and system.

create_system_path()[source]
find_all_python_versions(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]
find_python_version(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None, sort_by_path=False)[source]

Find the python version which corresponds most closely to the version requested.

Parameters
  • int] major (Union[str,) – The major version to look for, or the full version, or the name of the target version.

  • minor (Optional[int]) – The minor version. If provided, disables string-based lookups from the major version field.

  • patch (Optional[int]) – The patch version.

  • pre (Optional[bool]) – If provided, specifies whether to search pre-releases.

  • dev (Optional[bool]) – If provided, whether to search dev-releases.

  • arch (Optional[str]) – If provided, which architecture to search.

  • name (Optional[str]) – Name of the target python, e.g. anaconda3-5.3.0

  • sort_by_path (bool) – Whether to sort by path – default sort is by version(default: False)

Returns

A new PathEntry pointer at a matching python version, if one can be located.

Return type

pythonfinder.models.path.PathEntry

classmethod parse_major(major, minor=None, patch=None, pre=None, dev=None, arch=None)[source]
rehash()[source]
reload_system_path()[source]

Rebuilds the base system path and all of the contained finders within it.

This will re-apply any changes to the environment or any version changes on the system.

property system_path
which(exe)[source]
property windows_finder