Function Repository Resource:

PythonPackageInstalledQ

Source Notebook

Test if a Python package can be accessed in your session

Contributed by: Arnoud Buzing

ResourceFunction["PythonPackageInstalledQ"][name]

gives True if the Python package name is installed, and False otherwise.

ResourceFunction["PythonPackageInstalledQ"][python,name]

checks if the package is installed for the given installation.

Examples

Basic Examples

Check if the specified Python package is installed:

In[1]:=
ResourceFunction["PythonPackageInstalledQ"]["wheel"]
Out[1]=
In[2]:=
ResourceFunction["PythonPackageInstalledQ"]["svglib"]
Out[2]=

Check a particular Python session:

In[3]:=
session = StartExternalSession["Python"]
Out[3]=
In[4]:=
ResourceFunction["PythonPackageInstalledQ"][session, "svglib"]
Out[4]=
In[5]:=
DeleteObject[session]

Check a specific Python installation using a path:

In[6]:=
path = ResourceFunction["FindPythonExecutable"][]
Out[6]=
In[7]:=
ResourceFunction["PythonPackageInstalledQ"][path, "pip"]
Out[7]=

Version History

  • 1.1.0 – 04 October 2022
  • 1.0.0 – 07 August 2019

Related Resources

License Information