0

I looked around on Google, and found that python has support for this through the scipy module. According to this StackExchange page, all you need to do is:

import scipy.io
mat = scipy.io.loadmat('file.mat')

When I try this in the python interface in blender though, I get the following error:

ModuleNotFoundError: No module named 'scipy'

Is there a way to get this module to work, or any other way to import a .mat file into bpy?

Thanks for the help!

Rublie14
  • 31
  • 3
  • 3
    You need to install scypi in Blender, or make Blender use the system Python. See https://blender.stackexchange.com/questions/161894/how-to-import-scipy-in-blender or https://blender.stackexchange.com/questions/106099/error-when-trying-to-import-scipy-module-to-blender – Ron Jensen Jun 03 '21 at 21:46
  • Thanks for the reply. I followed the links you gave me, and installed scipy, but if I try to import scipy inside blender it still gives the ModuleNotFoundError... I have tried it in multiple ways now and everytime I try to install scipy it tells me "Requirement already satisfied", saying that scipy is already installed. Why can Blender not see it? – Rublie14 Jun 03 '21 at 22:32
  • 1
    Did you install it inside Blender using the Blender console? – Ron Jensen Jun 03 '21 at 23:20
  • @RonJensen Yes I ran the get-pip.py file inside the python text editor inside blender, and afterwards I ran these commands inside the python console inside blender: `>>> import pip

    pip.main(['install', 'scipy'])`

    From that I got the following error: ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Program Files\\Blender Foundation\\Blender 2.92\\2.92\\python\\Lib\\site-packages\\scipy' Consider using the '--user' option or check the permissions. I don't know what to do with this though, as I have no idea how to add '--user' to this...

    – Rublie14 Jun 04 '21 at 08:40
  • 1
    Windows isn't letting you install because the folder is protected. Just for this step you can try running Blender as administrator. – Ron Jensen Jun 05 '21 at 02:49
  • @RonJensen Thank you for all the help so far! I thought of doing that as well, but unfortunately this error came up while I already was running Blender as administrator already... I think it could maybe work if I can somehow add the '--user' argument to the command, so if you have any tips on how to do that I would really appreciate that! – Rublie14 Jun 05 '21 at 09:57
  • 1
    did you try ["install", "scipy", "--user"] which would emulate the required pip cli command. (or navigate to folder and run pip from cli as admin) There are a number of posts on installing 3rd party modules. My 2c worth is look at making a virtual env running same python version as blender, and point blenders python to it. – batFINGER Jun 06 '21 at 15:25
  • @batFINGER I hadn't tried pip.main["install", "scipy", "--user"] yet, but unfortunately when I do, I get the following error: TypeError: 'function' object is not subscriptable... I barely understand what I am doing, as I am very inexperienced with this stuff, so I don't really understand what you say in the rest of your post. If you have any idea what went wrong when I ran that command I would love to hear it! Thanks. – Rublie14 Jun 07 '21 at 14:13
  • 1
    pip.main([...]) Suggest googling python error messages if unsure of their meaning. – batFINGER Jun 07 '21 at 15:12
  • @batFINGER aaah sorry for my negligence. The command worked, and it said it Successfully installed scipy-1.6.3. The only problem now is that if I try the import scipy command, it still gives me the error ModuleNotFoundError: No module named 'scipy'... How is that even possible if it was literally installed through the blender python console? I already googled this many times, but then I get back to where I started, so your help is the only lead I have right now haha – Rublie14 Jun 07 '21 at 15:41
  • 1
    Not on windows. The "user" folder used by pip is not added to python path by blender python (sites.py) Installing using --user installs on linux to $HOME/.local/lib/python3.7/site-packages add corresponding path for windows (look it up in pip docs) to sys.path – batFINGER Jun 07 '21 at 15:46
  • @batFINGER I added that to my blender path using the append command, but still no dice. I feel like blender can't see the package for some reason. – Rublie14 Jun 07 '21 at 16:13

0 Answers0