This is because your operating system has defaulted to python3
since python 2 is officially no longer supported by the python development team since the beginning of 2020 , this does not seen a radical , bleeding edge position.
The very first line of your tutorial says to add the command interpreter as the first line ( as is standard for any script ).
First of all create a file hello_world.py and make it executable with the Python interpreter with the well-known directive:
#!/usr/bin/env python
The gcodetools script has a valid py2 executable in first line as shown above.
Why is this not being used. As I understand it, python calls a new instance of the interpreter for each process. It seems that inkscape is just calling "python" instead of the specified interpreter.
You can get it to work by patching the py files so they have `python2` instead of just `python` in their bang lines
thanks, so why doesn't it work with /usr/bin/python2 in the bang line as I posted above. I'm guessing this was changed in the script bang line by the distro to take account of default python now being py3. If this is wrong for some reason, I will open bug with the distro, but I don't see why it is not calling py2, it should work.
Again this does not seem to work. I reinstalled Inkscape from distro, changed bang line to /usr/bin/env python2 and get the same errors which indicate it is not using py2 but py3.
File "gcodetools.py", line 102 def bezierslopeatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t): ^ SyntaxError: invalid syntax
[BTW what is wrong with the 'code' tags on the forum here, the above line was three lines, it gets reduced to one and it is not marked as code. ]
Many thanks, that is better than me finding random patch files and hoping they work and are current.
since python two is now abandonned by the python team and support is ended, Inkscape really should have a realease which is py3 compatible. This all looks rather shakey. doctormo tells me I'm using an "older" version but this is the official current release.
I installed from the provide gitlab repository, it gets a little further, but there may still be some issues. I suspect the following error is still py3 issue. Any ideas.
I'll quote the output since code tags seem broken.
Orientation points have not been defined! A default set of orientation points has been automatically added.
Cutting tool has not been defined! A default tool has been automatically added.
Traceback (most recent call last): File "gcodetools.py", line 6751, in <module> gcodetools.affect() File "/usr/share/inkscape/extensions/inkex.py", line 289, in affect self.effect() File "gcodetools.py", line 6677, in effect self.path_to_gcode() File "gcodetools.py", line 4606, in path_to_gcode [ self.parse_curve([subpath], layer) for subpath in csp ] File "gcodetools.py", line 4606, in <listcomp> [ self.parse_curve([subpath], layer) for subpath in csp ] File "gcodetools.py", line 3750, in parse_curve c += biarc(sp1,sp2,0,0) if w==None else biarc(sp1,sp2,-f(w[k][i-1]),-f(w[k][i])) File "gcodetools.py", line 2327, in biarc TS, TE = TS.unit(), TE.unit() File "gcodetools.py", line 1674, in unit if h: return self / h TypeError: unsupported operand type(s) for /: 'P' and 'float'
here's a bug with a couple of fixes. Could you look it over and see whether they are correct. It runs on flat XY monochrome svg. Needs more testing but potentially fixed.
Thank you all for you contribution. my own issue is very similar, it is my inability to save file as gcode, even after adding gcode extension to Inkscape.
Please start a new topic for your problem. In that message, please tell us which extension you're using. Also please tell us your Inkscape version and operating system.
Hi, I just wanted to test the gcodetools extension and it fails at the first hurdle.
File "gcodetools.py", line 102 def bezierslopeatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t): ^ SyntaxError: invalid syntax
A quick search shows a few other reports of this but did not find any solutions. Is this a python version issue or what .
Thanks for any advice this tool looks like just what I need.
This is because your operating system has defaulted to python3 and you are using an older version of Inkscape.
that is true:
ls -ail `which python ` 430263 lrwxrwxrwx. 1 root root 9 Dec 15 17:19 /bin/python -> ./python3
ls -ail /usr/bin/python2 410620 lrwxrwxrwx. 1 root root 9 Oct 21 14:13 /usr/bin/python2 -> python2.7
but
#! /usr/bin/python2 -s
so having specified the interpreter to use and it points to a valid exec, why is it seeming to run under py3 .
{sorry, not sure what the "code" formatting is going to do, seems odd. apparently it does not work at all. }
since python 2 is officially no longer supported by the python development team since the beginning of 2020 , this does not seen a radical , bleeding edge position.
The very first line of your tutorial says to add the command interpreter as the first line ( as is standard for any script ).
https://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial
The gcodetools script has a valid py2 executable in first line as shown above.
Why is this not being used. As I understand it, python calls a new instance of the interpreter for each process. It seems that inkscape is just calling "python" instead of the specified interpreter.
I am using the latest version in the distro ( fedora ).
Your website shows this be the current release.
https://inkscape.org/release/inkscape-0.92.4/
Why do you say I'm using and "older" version. In what version is this resolved, where can I down load versions of the extensions which are py3 ready.
Thanks.
The latest version of Inkscape is 1.0, it's currently in beta as it's having trouble being born. But it's certainly a much better release.
You can get it to work by patching the py files so they have `python2` instead of just `python` in their bang lines.
Or by using the extensions from the not-yet-released 0.92.5: https://gitlab.com/inkscape/inkscape/blob/0.92.x/share/extensions
Those have been updated for Python 3, but have not undergone the radical changes that would make some of them incompatible with 0.92.x versions.
thanks, so why doesn't it work with /usr/bin/python2 in the bang line as I posted above. I'm guessing this was changed in the script bang line by the distro to take account of default python now being py3. If this is wrong for some reason, I will open bug with the distro, but I don't see why it is not calling py2, it should work.
Again this does not seem to work. I reinstalled Inkscape from distro, changed bang line to /usr/bin/env python2 and get the same errors which indicate it is not using py2 but py3.
File "gcodetools.py", line 102 def bezierslopeatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t): ^ SyntaxError: invalid syntax
[BTW what is wrong with the 'code' tags on the forum here, the above line was three lines, it gets reduced to one and it is not marked as code. ]
Many thanks, that is better than me finding random patch files and hoping they work and are current.
since python two is now abandonned by the python team and support is ended, Inkscape really should have a realease which is py3 compatible. This all looks rather shakey. doctormo tells me I'm using an "older" version but this is the official current release.
I installed from the provide gitlab repository, it gets a little further, but there may still be some issues. I suspect the following error is still py3 issue. Any ideas.
I'll quote the output since code tags seem broken.
Thanks, can you report that as an issue at https://inkscape.org/report , so it can be fixed before the release of Inkscape 0.92.5, please?
here's a bug with a couple of fixes. Could you look it over and see whether they are correct. It runs on flat XY monochrome svg. Needs more testing but potentially fixed.
https://gitlab.com/inkscape/inbox/issues/1589
I won't be able to look into it personally, but I hope someone else will. It would be nice to have that working for 0.92.5.
To post strings, use the paragraph format dropdown menu selection "Formatted".
Have a nice day.
TD
thanks for the workaround, I bear that in mind in the furture. maybe someone can fix the "code" tags.
Thank you all for you contribution. my own issue is very similar, it is my inability to save file as gcode, even after adding gcode extension to Inkscape.
Please, someone should kindly tell me what to do.
Thanks.
Please start a new topic for your problem. In that message, please tell us which extension you're using. Also please tell us your Inkscape version and operating system.
Should work like that"
def bezierslopeatt(just_change, t):
((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)) = just_change
ax, ay, bx, by, cx, cy, x0, y0 = bezmisc.bezierparameterize(((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)))
dx = 3 * ax * (t ** 2) + 2 * bx * t + cx
dy = 3 * ay * (t ** 2) + 2 * by * t + cy
if dx == dy == 0:
dx = 6 * ax * t + 2 * bx
dy = 6 * ay * t + 2 * by
if dx == dy == 0:
dx = 6 * ax
dy = 6 * ay
if dx == dy == 0:
print_("Slope error x = %s*t^3+%s*t^2+%s*t+%s, y = %s*t^3+%s*t^2+%s*t+%s, t = %s, dx==dy==0" % (
ax, bx, cx, dx, ay, by, cy, dy, t))
print_(((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)))
dx, dy = 1, 1
return dx, dy