Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Deploy a Python virtual environment
|
ResourceFunction["CreatePythonVirtualEnvironment"]["dir"] creates a Python virtual environment with a directory name "dir", using the default Python system. |
|
|
ResourceFunction["CreatePythonVirtualEnvironment"][spec,"dir"] creates a Python virtual environment using the Python system specified by spec. |
Create a new virtual environment:
| In[1]:= |
| Out[1]= |
The environment is registered and ready to use:
| In[2]:= |
| Out[2]= | ![]() |
Start a new Python session in the new environment:
| In[3]:= |
| Out[3]= |
| In[4]:= |
| Out[4]= | ![]() |
Evaluate code in the session:
| In[5]:= |
| Out[5]= |
End the session and delete the environment:
| In[6]:= |
| In[7]:= |
| Out[7]= |
Create a new virtual environment using the default Python system:
| In[8]:= |
| Out[8]= |
| In[9]:= |
| Out[9]= | ![]() |
Delete the environment:
| In[10]:= |
| Out[10]= |
Create a new virtual environment based on another Python version:
| In[11]:= |
| Out[11]= |
| In[12]:= |
| Out[12]= | ![]() |
Delete the environment:
| In[13]:= |
| Out[13]= |
Create a virtual environment outside the current working directory:
| In[14]:= |
| Out[14]= |
| In[15]:= |
| Out[15]= |
Delete the environment:
| In[16]:= |
| Out[16]= |
Virtual environments are perfect for experimenting with a new system version or a new version of a complex package with multiple dependencies without affecting other Python systems. Here is a set of packages installed in the default Python instance:
| In[17]:= |
| Out[17]= |
Create a new virtual environment:
| In[18]:= |
| Out[19]= |
At the outset, the new environment has only the default package set:
| In[20]:= |