Python library imports in scripting

Disclaimer that I am new to developing python plugins for blender and bpy but I am struggling with importing python librarys into the blender environment.

For example, I am trying to import matplotlib into my code but I am always getting ModuleNotFoundError. I have accessed blender’s python through the terminal, updated the pip version and still no success. The import claims to already be satisfied on my computer, but of course blender is not able to access it.

I am including the following sys path append to where the requirement is already satisfied but blender is still not able to import it correctly.
sys.path.append(‘Path/To/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages’)

Any suggestions? Thanks!

This forum is for developing Blender itself, for questions about Python add-on development please use one of the community websites. Blender stack exchange has various questions similar to this.

Note you can make Blender use packages from a compatible Python installation on your system with the --python-use-system-env command line flag. For distributing a self contained add-on you would need to bundle the packages somehow.

2 Likes

Thanks for your reply, apologies for using the wrong forum