Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Install a Python package
ResourceFunction["PythonPackageInstall"]["name"] installs the Python package "name". | |
ResourceFunction["PythonPackageInstall"][{"name1","name2",…}] installs packages "namei". | |
ResourceFunction["PythonPackageInstall"][packages] installs the specified versions of the packages. | |
ResourceFunction["PythonPackageInstall"][python,packages] installs for the given Python installation. |
"InstalledDependencies" | an association of installed package dependencies |
Install a Python package:
In[1]:= |
Out[1]= |
Uninstall it:
In[2]:= |
Out[2]= |
Install a package with dependencies:
In[3]:= |
Out[3]= |
List the installed dependencies:
In[4]:= |
Out[4]= |
Uninstall the package with its dependencies:
In[5]:= |
Out[5]= |
Install several packages:
In[6]:= |
Out[6]= |
Uninstall the packages:
In[7]:= |
Out[7]= |
Specify the required version using the Python convention:
In[8]:= |
Out[8]= |
Clean up:
In[9]:= |
Out[9]= |
Specify the version as a rule:
In[10]:= |
Out[10]= |
In[11]:= |
Out[11]= |
Or as an association:
In[12]:= |
Out[12]= |
In[13]:= |
Out[13]= |
Make use of the same external session:
In[14]:= |
Out[14]= |
In[15]:= |
Out[15]= |
In[16]:= |
Out[16]= |
End the session:
In[17]:= |
In case of an error, the Failure object may contain a useful information returned by the underlying pip install command:
In[18]:= |
Out[19]= |
PythonPackageInstall returns a Success object if the required version is already installed, or not specified:
In[20]:= |
Out[20]= |
In[21]:= |
Out[21]= |
In[22]:= |
Out[22]= |
In[23]:= |
Out[23]= |
If the versions do not match, PythonPackageInstall returns a Failure object:
In[24]:= |
Out[24]= |
Both Success and Failure objects with the tag "PythonPackageAlreadyInstalled" contain the location of the installed package:
In[25]:= |
Out[25]= |
In[26]:= |
Out[26]= |
In[27]:= |
This work is licensed under a Creative Commons Attribution 4.0 International License