r/OpenPythonSCAD • • Apr 04 '25

Did loading libraries change in the new version? (2025-04-02)

I think this happened in 2025-03-31 as well...

Trying to load:

from openscad import *

from gcodepreview import *

gc_file = "vcarvetest.nc"

gcp = gcodepreview(True, False, False)

gcp.previewgcodefile(gc_file)

and am getting:

Running Python 3.11.5 in venv ''. ERROR: Traceback (most recent call last): File "<string>", line 3, in <module> ModuleNotFoundError: No module named 'gcodepreview'

Execution aborted

where File | Show Library Folder opens: C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries

which contains:

"C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.py" and "C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.scad"

3 Upvotes

13 comments sorted by

View all comments

Show parent comment

2

u/WillAdams Apr 05 '25

Thanks!

I think I'll just use the Python folder I was using previously for the nonce if I need to use this before the next release.

2

u/gadget3D Apr 06 '25

i have uploaded a new windows installer with 2025-04-06

this one fixed the sys.path issue.

also it fixed 2 segfaults which you hopefully did not hit yet

2

u/WillAdams Apr 07 '25

Will have to check. d/l'd and installed:

OpenSCAD version 2025.04.06 (git )

but still getting:

Running Python 3.11.5 in venv ''. ERROR: Traceback (most recent call last): File "<string>", line 3, in <module> ModuleNotFoundError: No module named 'gcodepreview'

Execution aborted

Is there some configuration I need to do in venv?

1

u/gadget3D Apr 07 '25

can you paste the content of your sys.path

import sys

print(sys.path)

2

u/WillAdams Apr 07 '25 edited Apr 08 '25

That results in:

Running Python 3.11.5 in venv ''. ['C:\Program Files\libraries\python:C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries:', 'C:\Program Files\PythonSCAD\python311.zip', 'C:\Users\willa\AppData\Local\Programs\Python\Python311\Lib', 'C:\Users\willa\AppData\Local\Programs\Python\Python311\DLLs', 'C:\Program Files\PythonSCAD', 'C:\Program Files\PythonSCAD\Lib']

which seems right/like it would work...

and after quitting and re-launching and clearing out a bunch of files and so forth, it is working again.

I believe the problem was the file wasn't trusted --- I've been using:

"C:\Program Files\PythonSCAD\openscad.exe" --trust-python

as the target in the dock icon --- could that have stopped working?

Except now I'm getting:

Running Python 3.11.5 in venv ''. ERROR: Traceback (most recent call last): File "<string>", line 9, in <module> File "C:\Users/willa/OneDrive/Documents/OpenSCAD/libraries\gcodepreview.py", line 1621, in previewgcodefile gc_file = open(gc_file, 'r') ^ FileNotFoundError: [Errno 2] No such file or directory: 'vcarvetest.nc'

Execution aborted

when I have:

"C:\Users\willa\OneDrive\Desktop\vcarvetest.nc"

on the Desktop as well....

But, when I thought to change the line to:

gc_file = "C:/Users/willa/OneDrive/Desktop/vcarvetest.nc"

it worked.

Did get one new message:

DEPRECATED: output is deprecated, please use show() instead

and will have to look into that later.

1

u/gadget3D Apr 08 '25

I think ultimately everythig works as expected.

vcarvetest.nc could not be opened because without path pythonscad wants to open it from the PythonSCAD program folder.

output() is now deprecated, use show() instread

Finally I am happy, that you are running on a working pythonscad again

2

u/WillAdams Apr 08 '25

vcarvetest.nc could not be opened because without path pythonscad wants to open it from the PythonSCAD program folder.

It was working to open it from the same folder which the .py was in (which was really convenient) --- if that could be restored as the default behaviour, that would have my vote.

Thanks!

2

u/gadget3D Apr 08 '25

yes of course. i just did not realize, that this path got missed.

1

u/gadget3D Apr 08 '25

https://github.com/pythonscad/pythonscad/commit/46a535129f12a909a48d2f41252c475df1a9c0c7

got small doubts that that worked before because the python engine never knew the absolute path early enough.

But now after some restructuring, it does.

1

u/WillAdams Apr 07 '25

Will do so this evening when I'm home from my day job.