# Running external python scripts error

**URL:** <https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207>\
**Category:** 3rd Party Modules\
**Created:** [February 22, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207 "2024-02-22T18:31:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Zhao1](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Ethan\_Zhao1](https://forum.inductiveautomation.com/u/Ethan_Zhao1)\
**Post date:** [February 22, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/1 "2024-02-22T18:31:48Z")

</div>

I wrote a scripts to read a sensor value from NIDAQ , in pycharm it works.  
But in Script Console , there is an error.  
message = f'{message}\n\nTask Name: {task\_name}'  
^  
SyntaxError: no viable alternative at input ''{message}\n\nTask Name: {task\_name}''

The code is here: import nidaqmx  
import time

# Initialize DAQ Device

task = nidaqmx.Task()  
task.ai\_channels.add\_ai\_current\_chan("cDAQ1Mod4/ai2")  
task.start()

Ts = 1 # Sampling Time  
N = 5  
for k in range(N):  
value = task.read()  
air = (value-0.004)/0.016\*147  
print("Air Flow =", round(value,3), "CFM")  
time.sleep(Ts)

# Terminate DAQ Device

task.stop()  
task.close()

Thank you.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 22, 2024, 6:33pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/2 "2024-02-22T18:33:24Z")

</div>

At the very least, you need to import this 3rd party library so that Ignition can use it: [Libraries | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/python-scripting/libraries#importing-3rd-party-libraries)

This library will need to be compatible with Python 2.7 and not use any CPython/native code.

---

<div class="post-metadata">

**Author:** ![Ethan\_Zhao1](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Ethan\_Zhao1](https://forum.inductiveautomation.com/u/Ethan_Zhao1)\
**Post date:** [February 22, 2024, 6:51pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/3 "2024-02-22T18:51:08Z")

</div>

The file "task.py" is in the "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib ".

The following is from NI website:

The nidaqmx package contains the Application Programming Interface (API) for interacting with the NI-DAQmx driver and it is [supported](http://nidaqmx-python.readthedocs.io/en/latest/) on Windows using CPython 2.7, 3.4+, PyPy2, and PyPy3.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 22, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/4 "2024-02-22T19:05:10Z")

</div>

Jython (and Python) 2.7 do not have "f" strings.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 22, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/5 "2024-02-22T19:05:49Z")

</div>

> [@Ethan\_Zhao1](#):
>
> on Windows using CPython 2.7, 3.4+, PyPy2, and PyPy3

I don't see Jython in that list.

---

<div class="post-metadata">

**Author:** ![Ethan\_Zhao1](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Ethan\_Zhao1](https://forum.inductiveautomation.com/u/Ethan_Zhao1)\
**Post date:** [February 22, 2024, 7:30pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/6 "2024-02-22T19:30:50Z")

</div>

Thank you everyone!

That means I cannot use that library in ignition.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 22, 2024, 8:02pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/7 "2024-02-22T20:02:32Z")

</div>

Not directly no. You can always shell out to it if you have CPython on the computer in general and using `system.util.execute` or `ProcessBuilder`. You can find examples throughout the forum like here [Subprocess & system.util.execute](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329)

---

<div class="post-metadata">

**Author:** ![Ethan\_Zhao1](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Ethan\_Zhao1](https://forum.inductiveautomation.com/u/Ethan_Zhao1)\
**Post date:** [February 22, 2024, 8:14pm UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/8 "2024-02-22T20:14:48Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![rey.ch](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rey.ch](https://forum.inductiveautomation.com/u/rey.ch)\
**Post date:** [March 24, 2025, 11:33am UTC](https://forum.inductiveautomation.com/t/running-external-python-scripts-error/86207/9 "2025-03-24T11:33:49Z")

</div>

Hey, did the solution with **`system.util.execute`** work for you? I’m facing a similar issue where I need to read sensors data from **NI-DAQmx** and would appreciate any insights or updates you have on how it worked for you!
