프로그램 사용/Blender

bpy 설치 + 간단 테스트

구차니 2026. 7. 12. 21:57

ubuntu 22.04 에서 해서 그런가 에러가 난다

$ pip3 install bpy
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement bpy (from versions: none)
ERROR: No matching distribution found for bpy

 

$ pip install bpy==3.6.0 --extra-index-url https://download.blender.org/pypi/
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://download.blender.org/pypi/
Collecting bpy==3.6.0
  Downloading bpy-3.6.0-cp310-cp310-manylinux_2_28_x86_64.whl (371.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 371.4/371.4 MB 10.2 MB/s  0:00:36
Collecting cython (from bpy==3.6.0)
  Downloading cython-3.2.8-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (4.2 kB)
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from bpy==3.6.0) (1.21.5)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from bpy==3.6.0) (2.25.1)
Collecting zstandard (from bpy==3.6.0)
  Downloading zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (3.3 kB)
Downloading cython-3.2.8-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (3.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.5/3.5 MB 9.6 MB/s  0:00:00
Downloading zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (5.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/5.6 MB 10.0 MB/s  0:00:00
Installing collected packages: zstandard, cython, bpy
   ━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/3 [cython]  WARNING: The scripts cygdb, cython and cythonize are installed in '/home/minimonk/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed bpy-3.6.0 cython-3.2.8 zstandard-0.25.0

[링크 : https://pypi.org/project/bpy/]

 

구글 ai 개요에 의한 추천

$ python3
Python 3.10.12 (main, Jun 22 2026, 18:55:27) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy
>>> 
>>> # 1. 기존 큐브 삭제 및 새로운 큐브 생성
>>> bpy.ops.object.select_all(action='DESELECT')
{'FINISHED'}
>>> if "Cube" in bpy.data.objects:
...     bpy.data.objects["Cube"].select_set(True)
...     bpy.ops.object.delete()
... 
{'FINISHED'}
>>> bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
{'FINISHED'}
>>> cube = bpy.context.active_object
>>> 
>>> # 2. 카메라 설정
>>> bpy.ops.object.camera_add(location=(7, -7, 5))
{'FINISHED'}
>>> camera = bpy.context.active_object
>>> camera.rotation_euler = (0.785, 0, 0.785) # 약 45도 회전
>>> bpy.context.scene.camera = camera
>>> 
>>> # 3. 조명(Light) 설정
>>> bpy.ops.object.light_add(type='SUN', location=(5, -5, 10))
{'FINISHED'}
>>> light = bpy.context.active_object
>>> light.data.energy = 1000
>>> 
>>> # 4. 렌더링 설정 및 실행
>>> scene = bpy.context.scene
>>> scene.render.image_settings.file_format = 'PNG'
>>> scene.render.filepath = "/tmp/render_output.png"
>>> 
>>> # 렌더링 시작
>>> bpy.ops.render.render(write_still=True)
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
Fra:1 Mem:42.56M (Peak 43.65M) | Time:00:00.98 | Syncing Light
Fra:1 Mem:42.56M (Peak 43.65M) | Time:00:00.98 | Syncing Camera
Fra:1 Mem:42.56M (Peak 43.65M) | Time:00:00.98 | Syncing Cube
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:02.32 | Syncing Camera.001
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:02.32 | Syncing Sun
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:02.35 | Rendering 1 / 64 samples
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:03.47 | Rendering 26 / 64 samples
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:03.89 | Rendering 51 / 64 samples
Fra:1 Mem:42.60M (Peak 43.65M) | Time:00:04.10 | Rendering 64 / 64 samples
Saved: '/tmp/render_output.png'
 Time: 00:04.73 (Saving: 00:00.53)

{'FINISHED'}
>>> 
>>> print("렌더링 완료! 저장 경로:", scene.render.filepath)
렌더링 완료! 저장 경로: /tmp/render_output.png
>>> bpy.ops.wm.save_as_mainfile(filepath="test.blend")
Info: Total files 0 | Changed 0 | Failed 0
Info: Saved "test.blend"
{'FINISHED'}

 

카메라가 위치 잘못 조정되었는지 이상하게 나오긴 했는데

아무튼 이렇게 렌더도 가능하다.

특이한건.. gui 로는 보이지도 않고 수행된다는 점.

 

 

test.blend 열어보니 기본 카메라가 있는데 또 추가해서 이상하게 보이는 느낌 

 

blend 파일을 읽어서

저장할 경로를 지정하고 

import bpy
import mathutils

# .blend 파일 로드
bpy.ops.wm.open_mainfile(filepath="test.blend")

camera = bpy.data.objects.get("Camera")
if camera is None:
    raise RuntimeError("Camera not found")

scene = bpy.context.scene

scene.render.image_settings.file_format = 'PNG'

camera_locations = [
    (5.0, -5.0, 3.0),
    (0.0, -7.0, 3.0),
    (-5.0, -5.0, 3.0),
]

for i, loc in enumerate(camera_locations):
    camera.location = mathutils.Vector(loc)
    # Blender 2.80+
    bpy.context.view_layer.update()
    scene.render.filepath = f"frame_{i:03d}.png"
    bpy.ops.render.render(write_still=True)
    print(f"Render {i} complete")

 

EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
EGL Error (0x3009): EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).
Fra:1 Mem:42.72M (Peak 43.80M) | Time:00:00.17 | Syncing Cube
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:00.25 | Syncing Light
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:00.25 | Syncing Camera
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:00.27 | Rendering 1 / 64 samples
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:01.50 | Rendering 26 / 64 samples
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:02.48 | Rendering 51 / 64 samples
Fra:1 Mem:42.75M (Peak 43.80M) | Time:00:03.02 | Rendering 64 / 64 samples
Saved: 'frame_000.png'
 Time: 00:03.44 (Saving: 00:00.31)

{'FINISHED'}
Render 0 complete
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.03 | Syncing Cube
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.03 | Syncing Light
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.03 | Syncing Camera
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.06 | Rendering 1 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.66 | Rendering 26 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:01.02 | Rendering 51 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:01.21 | Rendering 64 / 64 samples
Saved: 'frame_001.png'
 Time: 00:01.53 (Saving: 00:00.23)

{'FINISHED'}
Render 1 complete
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.00 | Syncing Cube
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.00 | Syncing Light
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.00 | Syncing Camera
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.00 | Rendering 1 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.56 | Rendering 26 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:00.93 | Rendering 51 / 64 samples
Fra:1 Mem:42.75M (Peak 42.75M) | Time:00:01.12 | Rendering 64 / 64 samples
Saved: 'frame_002.png'
 Time: 00:01.43 (Saving: 00:00.24)

{'FINISHED'}
Render 2 complete

 

좌표 문제겠지만 아무튼 렌더가 된다!