JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
570 stars 75 forks source link

Blender with Anaconda environment error on Blender:Start #113

Open Failxxx opened 2 years ago

Failxxx commented 2 years ago

I recently installed Blender 3.0. I have chosen to use an anaconda environment in order to install python packages which would then be available in Blender. I have correctly linked the python folder of my anaconda env here: C:\Program Files\Blender Foundation\Blender 3.0\3.0. If I launch blender from the anaconda prompt, everything is working fine. However, when I use the Blender:Start command in VSCode, I have the following error message:

Read prefs: C:\Users\felix\AppData\Roaming\Blender Foundation\Blender\3.0\config\userpref.blend
Unable to find the python binary, the multiprocessing module may not be functional!
[{'load_dir': 'c:\\Users\\felix\\Documents\\IMAC\\quantum_nodes\\quantum_nodes', 'module_name': 'quantum_nodes'}]
Traceback (most recent call last):
  File "c:\Users\felix\.vscode\extensions\jacqueslucke.blender-development-0.0.16\pythonFiles\launch.py", line 14, in <module>
    blender_vscode.startup(
  File "c:\Users\felix\.vscode\extensions\jacqueslucke.blender-development-0.0.16\pythonFiles\include\blender_vscode\__init__.py", line 8, in startup     
    from . import installation
  File "c:\Users\felix\.vscode\extensions\jacqueslucke.blender-development-0.0.16\pythonFiles\include\blender_vscode\installation.py", line 7, in <module>
    from . environment import python_path, use_own_python
  File "c:\Users\felix\.vscode\extensions\jacqueslucke.blender-development-0.0.16\pythonFiles\include\blender_vscode\environment.py", line 6, in <module> 
    python_path = Path(sys.executable)
  File "c:\Program Files\Blender Foundation\Blender 3.0\3.0\python\lib\pathlib.py", line 1082, in __new__
    self = cls._from_parts(args, init=False)
  File "c:\Program Files\Blender Foundation\Blender 3.0\3.0\python\lib\pathlib.py", line 707, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "c:\Program Files\Blender Foundation\Blender 3.0\3.0\python\lib\pathlib.py", line 691, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Saved session recovery to 'C:\Users\felix\AppData\Local\Temp\quit.blend'

Terminal will be reused by tasks, press any key to close it.

The second line of the message (Unable to find the python binary, the multiprocessing module may not be functional!) is strange because it does not appear when I launch Blender through the anaconda prompt. I think the issue could come from here, so I tried to set up some environment variables in the Path (in my Windows parameters) variable, but it does not do anything. Has anyone already faced this issue?

Mateusz-Grzelinski commented 1 month ago

logic for finding python was changed relatively revently. Try newest blender. Otherwise I recommend this nice lecture: https://projects.blender.org/blender/blender/src/branch/main/source/blender/python/intern/bpy_interface.cc#L438

Mateusz-Grzelinski commented 1 month ago

oh, wait, this error is on our part. This is very weird scenario, our logic might not handle it well. Try

  1. newest extension from store
  2. extension from master branch

Otherwise I need from you to tell me how do I find python interpreter path when using anaconda & blender. Usually one of those work:

getattr(bpy.app, "binary_path_python")
sys.executable
bpy.app.binary_path