- Posts: 596
- Thank you received: 0
Python Component - $PATH
3 years 3 months ago #276122
by zz912
Replied by zz912 on topic Python Component - $PATH
Here:
Attachment not found
Please Log in to join the conversation.
3 years 3 months ago #276123
by cmorley
Replied by cmorley on topic Python Component - $PATH
You posted the error message (note line 2):
You might not be running the file you think you are.
But the file you posted line 2 is different:halcmd: Traceback (most recent call last):
File "/home/zdenek/linuxcnc/linuxcnc-2.8.4/bin/passthrough", line 2, in <module>
h = hal.component("passthrough")
NameError: name 'hal' is not defined
Code:
1 #!/usr/bin/env python3
2 import hal, time
3 h = hal.component("passthrough")
4 h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
5 h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
6 h.ready()
7 try:
8 while 1:
9 time.sleep(1)
10 h['out'] = h['in']
11 except KeyboardInterrupt:
12 raise SystemExit
You might not be running the file you think you are.
Please Log in to join the conversation.
3 years 3 months ago #276124
by cmorley
Replied by cmorley on topic Python Component - $PATH
Also I don't think 2.8 can run python3 code
Please Log in to join the conversation.
3 years 3 months ago #276125
by zz912
Replied by zz912 on topic Python Component - $PATH
Because, this is not halcompiled file.I will find the halcompiled file and send it tonight.But the file you posted line 2 is different:
Please Log in to join the conversation.
3 years 3 months ago #276196
by zz912
Replied by zz912 on topic Python Component - $PATH
/home/zdenek/linuxcnc/linuxcnc-2.9/bin/passthrough :
halcompile stole "import hal, time".
Why?
Code:
#!/usr/bin/python3.7
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
halcompile stole "import hal, time".
Why?
Please Log in to join the conversation.
3 years 3 months ago #276199
by phillc54
Replied by phillc54 on topic Python Component - $PATH
Try adding a blank line immediately before the import line in passthrough.py
Please Log in to join the conversation.
3 years 3 months ago #276223
by zz912
It helped. It works. Thank you.
/home/zdenek/linuxcnc/linuxcnc-2.9/passthrough.py
/home/zdenek/linuxcnc/linuxcnc-2.9/bin/passthrough
Is this a bug?
This example is here:
linuxcnc.org/docs/2.9/html/hal/halmodule..._basic_usage_example
Replied by zz912 on topic Python Component - $PATH
Try adding a blank line immediately before the import line in passthrough.py
It helped. It works. Thank you.
/home/zdenek/linuxcnc/linuxcnc-2.9/passthrough.py
Code:
#!/usr/bin/env python3
import hal, time
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
/home/zdenek/linuxcnc/linuxcnc-2.9/bin/passthrough
Code:
#!/usr/bin/python3.7
import hal, time
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
Is this a bug?
This example is here:
linuxcnc.org/docs/2.9/html/hal/halmodule..._basic_usage_example
Please Log in to join the conversation.
3 years 3 months ago #276274
by phillc54
Replied by phillc54 on topic Python Component - $PATH
Yes, it is a bug. A fix has been pushed to 2.9.
Please Log in to join the conversation.
3 years 3 months ago #276314
by zz912
Replied by zz912 on topic Python Component - $PATH
Please Log in to join the conversation.
Time to create page: 0.065 seconds
