vilemduha / blendercam

Automatically exported from code.google.com/p/blendercam
GNU General Public License v3.0
484 stars 119 forks source link

Automatic python package installation not working on Windows Machine #267

Closed ParsaJafarian closed 3 months ago

ParsaJafarian commented 4 months ago

Problem Summary

While activating Blendercam add-on, I got this error: image

However, instead of the "No module named 'curve_simplify' ", before I got the "No module named 'shapely' ". As such, I was forced to manually pip install the packages through the command line.

I would like to automate this process so that future non-technical users don't go through manual python installation as well.

My manual installation fix

  1. Run powershell as Administrator
  2. Go to Blender python bin folder. In my case: cd C:\Program Files\Blender-4.2\4\python\bin
  3. Remove user system installs of required packages: pip uninstall shapely numpy Equation. This is so that the system packages and the local blender packages are not mixed.
  4. Install required packages using blender python environment: .\python.exe -m pip install numpy shapely Equation
  5. Restart Blender and the error is gone

Location of problem

I took a look at the code and the problem might take place inside scripts/addons/cam/__init__.py. Specifically at line 39 to 47:

try:
    import shapely
except ImportError:
    # pip install required python stuff
    subprocess.check_call([sys.executable, "-m", "ensurepip"])
    subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", " pip"])
    subprocess.check_call([sys.executable, "-m", "pip", "install", "shapely","Equation","opencamlib"])
    # install numba if available for this platform, ignore failure
    subprocess.run([sys.executable, "-m", "pip", "install", "numba"])

I am not sure what causes the automatic installation to not work as the code snippet looks mostly good but that's to figure out.

Software used

Disclaimer

I hope this issue helps as my contribution to Blendercam

pppalain commented 3 months ago

check for update. works with blender 4.1, 4.2 will work but it is unknown if everything works well.