You are not logged in.

#1 2025-04-16 17:16:29

WorldArtandMind
Member
Registered: 2025-04-14
Posts: 2

(Solved) Blender 4.4 + CAD Sketcher + Python3.13 = Error

TLDR:

I am trying to get CAD Sketcher on Blender 4.4 but my Python version 3.13 is newer than CAD Sketcher's 3.11. Looking for a workaround. I don't know how to do the Python scripts. smile Please Help!

Context:

-99% new to Python, scripts, CAD Sketcher, Blender

-90% new to Arch

-80% new to Linux

-System Info: r1L3llp.png

-Download Instruction for CAD Sketcher AiqQsPv.png (Notes to get Solvespace Python Module)

-CAD Sketcher Installed from from Zip file sYtr0i3.png (Displays Python error)

-Python 3.13 error message and py_slvs module installed aWvIYCI.png (CAD Sketcher is in Python 3.11)

-GitHub CAD Sketcher Bug discussion https://github.com/hlorus/CAD_Sketcher/issues/497 GitHub script solution kMM0tEl.png

-Script solution:

import tempfile
import zipfile
from pathlib import Path

# Open the source ZIP file
zip_path = Path("./CAD_Sketcher-main.zip")
with zipfile.ZipFile(zip_path, "r") as zip_ref:
    # Create a temporary directory
    with tempfile.TemporaryDirectory() as tmp_dir:
        tmp_path = Path(tmp_dir)
        zip_ref.extractall(tmp_path)
       
        # Rename .whl files
        for whl in tmp_path.glob("**/*.whl"):
            new_name = whl.name.replace("cp311", "cp313")
            print(f"Renaming {whl.name} to {new_name}")
            whl.rename(whl.parent / new_name)
       
        # Update the manifest before creating the new ZIP
        manifest = tmp_path / "CAD_Sketcher-main" / "blender_manifest.toml"
        if manifest.exists():
            manifest_str = manifest.read_text()
            manifest_str = manifest_str.replace("cp311", "cp313")
            manifest.write_text(manifest_str)
       
        # Create the new ZIP file
        new_zip_path = Path("./CAD_Sketcher-py313.zip")
        with zipfile.ZipFile(new_zip_path, "w") as new_zip:
            for file in tmp_path.rglob("*"):
                if file.is_file():  # Ensure it's a file
                    arc_name = str(file.relative_to(tmp_path))
                    new_zip.write(file, arc_name)

print("New ZIP archive created successfully.")

-Ran script in Blender received script error 80MlheA.png

-Currently sitting on the last script error

Python: Traceback (most recent call last):
  File "/Text", line 7, in <module>
  File "/usr/lib/python3.13/zipfile/__init__.py", line 1367, in __init__
    self.fp = io.open(file, filemode)
              ~~~~~~~^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'CAD_Sketcher-main.zip'

As mentioned in the beginning I am mostly clueless about Python and scripts. The solution is most likely easy I just don't have the knowledge. Any help or instruction would be greatly appreciated. I figure this post is a good stopping point as further tinkering may break something. Thank you.

Thank you @blackbookpro and everyone at https://github.com/hlorus/CAD_Sketcher/issues/497

For any other noobs like me:

-Had to figure out how to create the .py file from terminal. Used nano. (example: nano CAD_Sketcher_Python_Fix.py) copy, paste script and save to the location where CAD_Sketcher-main.zip was located.

-Once the file was created in the desired folder. I ran the .py (example: python CAD_Sketcher_Python_Fix.py) and it created the 313.zip

-Then I went to Blender > Edit > Preferences > Add-ons > Add-ons Setting > Install from disk > the 313.zip file

Works!

Only took me 4 days to figure out . . 8)

Last edited by WorldArtandMind (2025-04-18 01:48:44)

Offline

Board footer

Powered by FluxBB