I'm trying to use Visual Studio Code to develop Python Blender scripts, and I've run into an odd problem.
I already had Visual Studio Code installed (1.49.3) on my Windows 10 box, so I downloaded Blender (2.90.1) and the latest stable version of Python (3.9.0). I also installed Jacques Lucke's Blender Development extension.
I was able to connect Visual Studio Code to Blender. But when I ran the following test script:
import bpy
bpy.data.objects["Cube"].data.vertices[0].co.x += 2.0
bpy.ops.mesh.primitive_cube_add(location=(1, 0, 0))
Blender crashed, and I got the following error message:
Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF6091405F3
Module : blender.exe
Thread : 00002968
Writing: C:\Users\aschn\AppData\Local\Temp\blender.crash.txt
The terminal process "c:\Program Files\Blender Foundation\Blender 2.90\blender.exe '--python',
'c:\Users\aschn\.vscode\extensions\jacqueslucke.blender-development-0.0.12\pythonFiles\launch.py'"
terminated with exit code: 11.
However, the script works just fine when I run it directly in Blender (in its Scripting workspace).
So, I tried eliminating the line that creates a cube:
import bpy
bpy.data.objects["Cube"].data.vertices[0].co.x += 2.0
This script works fine from Visual Studio Code.
In short, from Visual Studio Code I can manipulate existing objects but I can't create a new one.
Any idea what's going on? I found a bunch of posts about the EXCEPTION_ACCESS_VIOLATION error, but the code that was causing the problem described in these posts was far more complex.