How to call a python script in gcode

More
1 year 9 months ago #319351 by Aciera

But I get the error


What error?

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago #319373 by Ehsan_R
Debug file information:
Note: Using POSIX realtime
/home/ehsan/linuxcnc/configs/sim.axis/axis.ini:82: executing 'import sys
sys.path.insert(0,"python")'
PythonPlugin: Python '3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0]'
initialize: module '/home/ehsan/linuxcnc/configs/sim.axis/python/toplevel.py' init failed:
Traceback (most recent call last):

File "/home/ehsan/linuxcnc/configs/sim.axis/python/toplevel.py", line 19, in <module>
import remap

File "/home/ehsan/linuxcnc/configs/sim.axis/python/remap.py", line 8

existing_filename = 'random_numbers.txt'

^

IndentationError: unindent does not match any outer indentation level

Interp ctor: can't instantiate Python plugin
/home/ehsan/linuxcnc/configs/sim.axis/axis.ini:82: executing 'import sys
sys.path.insert(0,"python")'
PythonPlugin: Python '3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0]'
initialize: module '/home/ehsan/linuxcnc/configs/sim.axis/python/toplevel.py' init failed:
Traceback (most recent call last):

File "/home/ehsan/linuxcnc/configs/sim.axis/python/toplevel.py", line 19, in <module>
import remap

File "/home/ehsan/linuxcnc/configs/sim.axis/python/remap.py", line 8

existing_filename = 'random_numbers.txt'

^

IndentationError: unindent does not match any outer indentation level

Python plugin configure() failed, status = -11
iNTERP_REMAP: Python plugin required for python=, but not available:
REMAP INI line:76 = M456 modalgroup=10 python=m456

note: MAXV max: 5.000 units/sec 300.000 units/min
note: LJOG max: 5.000 units/sec 300.000 units/min
note: LJOG default: 0.250 units/sec 15.000 units/min
A configuration error is preventing LinuxCNC from starting.
More information may be available when running from a terminal.
1978
Stopping realtime threads
Unloading hal components
Note: Using POSIX realtime

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago - 1 year 9 months ago #319382 by Aciera
in python indentation is part of the syntax. The line with 'existing_filename = 'random_numbers.txt' needs to be indented by one more space to match the lines above.
Code:
def m456(self):    import random    import os   existing_filename = 'random_numbers.txt'
Last edit: 1 year 9 months ago by Aciera.

Please Log in or Create an account to join the conversation.

Time to create page: 0.307 seconds
Powered by Kunena Forum