TylerGubala / blenderpy

Blender as a python module with easy-install
GNU General Public License v3.0
314 stars 30 forks source link

Error installing bpy through pip #122

Open mariocorradetti opened 2 years ago

mariocorradetti commented 2 years ago

I have tried to install bpy thorugh termial (pip) and also by PyCharm, but i obtain always this error regardless i have updated all the other libraries just in case. I don't know ho to resolve this. Please help me :(

Collecting bpy
  Using cached bpy-0.0.0a0.tar.gz (19 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: bpy
  Building wheel for bpy (setup.py): started
  Building wheel for bpy (setup.py): finished with status 'error'
  Running setup.py clean for bpy
Failed to build bpy
Installing collected packages: bpy
  Running setup.py install for bpy: started
  Running setup.py install for bpy: finished with status 'error'

  error: subprocess-exited-with-error

  python setup.py bdist_wheel did not run successfully.
  exit code: 1

  [20 lines of output]
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\blenderpy
  copying blenderpy\post_install.py -> build\lib.win-amd64-3.9\blenderpy
  copying blenderpy\__init__.py -> build\lib.win-amd64-3.9\blenderpy
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  Preparing the build environment
  Searching for compatible Blender online (this will take a while)
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v1 is an invalid version and will not be supported in a future release
    warnings.warn(
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v2 is an invalid version and will not be supported in a future release
    warnings.warn(
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v3 is an invalid version and will not be supported in a future release
    warnings.warn(
  error: [WinError 2] Impossibile trovare il file specificato
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for bpy
  error: subprocess-exited-with-error

  Running setup.py install for bpy did not run successfully.
  exit code: 1

  [22 lines of output]
  running install
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
    warnings.warn(
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\blenderpy
  copying blenderpy\post_install.py -> build\lib.win-amd64-3.9\blenderpy
  copying blenderpy\__init__.py -> build\lib.win-amd64-3.9\blenderpy
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  Preparing the build environment
  Searching for compatible Blender online (this will take a while)
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v1 is an invalid version and will not be supported in a future release
    warnings.warn(
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v2 is an invalid version and will not be supported in a future release
    warnings.warn(
  C:\Users\corra\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: softbody-stable-v3 is an invalid version and will not be supported in a future release
    warnings.warn(
  error: [WinError 2] Impossibile trovare il file specificato
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

Encountered error while trying to install package.
bpy
note: This is an issue with the package mentioned above, not pip.
EllieMo commented 2 years ago

I have the same problem (basically the same error message) trying to pip install bpy on mac python 3.9

AdamStormhardtGH commented 2 years ago

Just went through this. The pip page specifies >=3.7 and <3.8 so I'd suggest the following steps

ColtPtrHun commented 2 years ago

Same problem for me. Funny there's no 3.7 installer for windows, the only version this package works with: https://www.python.org/downloads/windows/ (@AdamStormhardtGH I assume this is why you suggested the virtual environment.)

AdamStormhardtGH commented 2 years ago

An update on this.

I ended up abandoning a pip installation after seeing some more issue and just leveraging the bpy installed as part of the blender package.

This lets me:

My new commands are using subprocess to just call the python command.

import subprocess

blender_job_command = f"blender {cwd}/src/blend/template_scene.blend --python {cwd}/src/scripts/my_main_python_script.py" 
subprocess.Popen(blender_job_command, shell=True, stdout=subprocess.PIPE)

Note that this has kinda made me have to work more modularly and pull a lot of the blender interaction out into more discrete steps, but it's pretty reliable.

If you're interested in doing this

Setup (MAC) - sorry I'm not sure how this will translate to windows =/. Maybe the windows linux subsystem will be compatible but I have not tested this :

Option 1: Locally (default)

Doing pip installs will default to local, which is okay if you want to add an environment variable in the next step.

Option 2: System level

Not an ideal fix, but it's removed some of the headaches around this bpy stuff. I haven't worked with a library which acts like this before. Hopefully it becomes a little more universally installable in the future.