> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/python-environment-and-imports.md).

# Python Environment & Imports

### Python Version

Grid Studio uses **Python 3.11.9** as its scripting environment.

Standard Python syntax, functions, data structures and modules can be used throughout the scripting system.

Grid Studio-specific functionality is available through the `sp` namespace.

The `sp` module is included in the project's **Global Imports** by default:

```python
import sp
```

Because Global Imports are available throughout the project, `import sp` does not need to be added manually to each individual script.

For example:

```python
print(sp.Camera1.coordinates.position.value)
```

### Global Imports

Imports that should be available throughout the project can be configured under:

**File → Project Settings → Scripts → Global Imports**

<div align="left"><figure><img src="/files/Co0ARlj4L66wNRCPaF0O" alt="" width="343"><figcaption></figcaption></figure></div>

For example:

```python
import sp
import time
from math import *
```

Global Imports are loaded automatically and are available to scripts throughout the project.

This is useful for modules or functions that are required by multiple scripts and avoids repeating the same imports in every script.

### External Python Libraries

Third-party Python libraries can also be added through **Global Imports**.

For example:

```python
import requests
```

When an external package is required, Grid Studio's Python package manager handles the corresponding dependency automatically.

This allows project scripts to use additional Python libraries alongside the modules included with Python itself.

{% hint style="info" %}
External libraries become project dependencies. When moving a project to another Grid Studio system, the required Python packages must also be available through the project's configured imports.
{% endhint %}

### Import Examples

A Global Imports configuration can contain multiple imports just like a regular Python script:

```python
import sp
import time
from math import *
import requests
```

Once configured, the imported modules and functions can be used directly from the project's scripting locations.

For example:

```python
current_time = time.time()
```

or, when using functions imported directly from a module:

```python
result = sin(1.0)
```
