# Python state script gives \`exec format error\`

**URL:** https://hub.mender.io/t/python-state-script-gives-exec-format-error/3104
**Category:** General Discussions
**Tags:** yocto, dunfell
**Created:** [January 19, 2021, 10:27pm UTC](https://hub.mender.io/t/python-state-script-gives-exec-format-error/3104 "2021-01-19T22:27:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![HerrMuellerluedensch](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/herrmuellerluedensch/32/513_2.png) [@HerrMuellerluedensch](https://hub.mender.io/u/HerrMuellerluedensch)
#### Post date: [January 19, 2021, 10:27pm UTC](https://hub.mender.io/t/python-state-script-gives-exec-format-error/3104/1 "2021-01-19T22:27:04Z")

</div>

Hey,  
I understood that I can write state scripts in python as long as it has the shebang on the top line. So, first question: is that correct?

Mine starts with :

```
#!/usr/bin/python3

import subprocess
import time
import re
import json
import os
import logging
from contextlib import contextmanager

...

```

Unfortunately I’m running into:

`‘ArtifactReboot\_Leave\_01\_fix\_readonly\_paths.py’: -1 : fork/exec /var/lib/mender/scripts/ArtifactReboot\_Leave\_01\_fix\_readonly\_paths.py:

When I execute the script manually by using standalone mender client it works fine. Any ideas? Is the `.py` ending an issue? Should I have a shell script that call the python script?

Thanks in advance!
