BlackStartx / PyCharm-Blender-Plugin

A PyCharm Plugin that simplify the development of Blender Add-On inside the PyCharm IDE.
MIT License
151 stars 12 forks source link

After following the installation, my PyCharm still does not give me bpy object introspection #8

Closed adamryczkowski closed 2 years ago

adamryczkowski commented 2 years ago

Hi!

I've managed to install it, and followed the configuration steps to the letter (to the best of my knowledge ;-) )

I've then created a new Blender Addon just as in the instructions you've provided.

The problem is that the template file __init__.py does start with import bpy, but PyCharm does not recognize that module.

I am able to reproduce my problems on Ubuntu 20.04 with Blender installed from Snap and PyCharm Professional 2022.1, and on MacOS (12.3.1) with Blender installed using the manual method from the blender.org with PyCharm CE 2022.1.

adamryczkowski commented 2 years ago

Another fact: on the Linux machine, when I try to debug my addon, I get the following output on the Blend-Charm panel:

Starting debug server at port 8,132
Use the following code to connect to the debugger:
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=8132, stdoutToServer=True, stderrToServer=True, suspend=False)
Waiting for process connection…
/snap/bin/blender --python /tmp/BlendCharm/pycharm_connector.py --

And the status bar keeps displaying "Waiting for process connection...".

BlackStartx commented 2 years ago

Hi Adam,

Sadly the bpy module is not included in almost every python libs by default since it's a specific Blender module.

In any case your IDE does not require to recognize the module for your add-on to work in Blender, but it's definetly better to have less red lines and auto-completition while coding.

To fix it, there are a lot of python packages that replicate the structure of that module, the one that I use is fake-bpy-module. It's very simple to install, you can use pip and after that all your IDEs should be able to find the module correctly!

For the second issue... I didn't test my plugin in a Linux enviroment since I have none at hand right now. It may require me to use a VM so it may take a while to find the cause.

One question... it looks you started it in debug-mode, does everything work in the default run-mode?

Thanks and sorry for the issues~

adamryczkowski commented 2 years ago

No need to be sorry. You pave the way for the future of using Blender in the scientific environment. Glitches are expected :-)

Thank you very much for the tip. It does help us. I will rise a separate ticket about the problem with the debug mode, to keep the conversation clean.