简体   繁体   中英

How to use blender through VSCode with python for integrating 2D widgets with 3D models

I am new to Blender community and has created some add-ons to model things through code..

However, I am failing to execute the same code through my IDE , IDLE and VS Code with all my paths set for Python 3.7.0 installed inside python folder of Blender 2.80 directory in C drive (cant use other version for VS Code as Blender extension in VS Code only supports python 3.7.0 and the same Python version is compatible with only Blender 2.80)

However I have installed UPBGE in another drive with latest versions of Python(3.9.1) and Blender(2.93 Alpha).. There, I manually installed latest version of Python like the one I had installed

So, I have my python interpreters at two following locations

C:\Program Files\Blender Foundation\Blender\2.80\python\python.exe

D:\Softwares\UPBGE\2.93\python\python.exe

Problems are as follows:

  1. When I check python version through command " py --version " it displays 3.9.1 even when interpreter selected as 3.7.0 in VS Code selected interpreter ambiguity

  2. Whenever I install any pypi module through cmd, it installs the module to older version, ie, 3.7.0 directory in C drive even when python 3.9.1 interpreter selected Blender stores its built in python interpreter inside bin directory inside python folder

  3. Whenever I try to run any script importing bpy stuff, it says bpy module is not present cannot find the module named bpy-types

  1. Installing python libraries into blender's python environment.

    <[Blender Python.exe path]> -m pip install <[Package Name]>

For example, in your case for UPBGE:

D:\Softwares\UPBGE\2.93\python\python.exe -m pip install <[Package Name]>

If the command fails you might need to add "pip" to you python env available here: https://bootstrap.pypa.io/get-pip.py

  1. For running a script that uses bpy you also need to use Blenders python.

    <[Blender Python.exe path]> <[Script Path]>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM