How do I install scipy for Blender 2.93 on Windows 10?

I’ve tried numerous advice to no avail… I just want to install the scipy module because an addon I have (Mesh Fairing 1.0.3) states that it’ll be more effective with scipy. The addon has a built-in button i Preferences for installing scipy, which gave this error:

WARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.
You should consider upgrading via the 'C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin\python.exe -m pip install --upgrade pip' command.

So I followed the suggestion and managed to successfully upgrade pip to version 21.1.2.

Now, I’m still unsuccessful trying to install scipy. All suggested methods I’ve come across seem outdated and I don’t know any last resort but to ask here:

What is the proper, working, current method to install scipy on Windows/Blender 2.93? I’m on a fresh 2.93 (installed yesterday) and haven’t changed Blender’s Python binary/path or anything like that, other than installed a few addons and upgraded pip to 21.1.2. Just looking for a confirmed working method, preferably broken down into steps.

What did you already achieve?
Do you at least get scipy installed? what are the error messages if not?
Can you execute a short python script (outside of blender) and try to import scipy?
Does blender/the addon shows an error message?

Scify is a blender independent python package and still actively maintained. So the offical installation page would be my first place to go: https://www.scipy.org/install.html. I would recommend:
pip install scipy or pip install --user scipy (as mentioned on the webpage)

I personally would - as an alternative - try anaconda(*) if pip does not work. But for one package that might be a little overkill.

(*) anaconda also adminstrates precompiled(?) python packages “like” pip. Additionally it provides the possibility to have different python installations and packages in parallel, organized in conda environments.

1 Like

would add --no-deps so there is no risk to break blender’s numpy by overriding

2 Likes

I wasn’t fully aware that the packages need to be installed into blenders python installation. Here is a way, which just worked for me:

  • start an administator console (type cmd in windows start menu and right-click “run as administrator” at ‘command prompt’)
  • cd your_blender_installation\python\bin
  • .\python -m pip install --no-deps scipy

You can check now if it really worked and where she installed it by running python:

  • .\python
    import scipy
    print(scipy.__file__)
    # should be: your_blender_installation\python\lib\site-packages\scipy\__init__.py
    ...
    exit()
    

You can now run blender and type the same in blender’s python console.

PS:
I didn’t use --no-deps but worth a try. if some incompatibilities occure, try running it without (preverably from a fresh blender installation :slight_smile:)
And to be honest I did run pip from within blender (with admin rights!) using subprocess and sys.executable like described here: https://stackoverflow.com/questions/12332975/installing-python-module-within-code. But the way describe above should work equally well if not weller :slight_smile:

1 Like

That helped me on the way, thanks. But entering that exact command would not install scipy in my Blender’s site-packages, but rather this folder:

C:\Users\ME\AppData\Roaming\Python\Python39\site-packages\scipy\

… so I had to change the command and add the correct target:

cd C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages

python -m pip install --no-deps scipy -t "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages"

Now scipy is finally available for me in Blender 2.93, so I’m happy!

the .\ infront of python should have ensured, that the local python is used and thus also used by pip. aparently it didn`t work. Anyway i am glad it worked out for you.

Glad it worked for you, however you are pretty lucky (by running python xxx if any python interpreter is available in the system path, you may end up to set wrong scipy version).
Your command line was missing --user option, and scipy is then installed in global site_package instead of local one.

  • cd your_blender_installation\python\bin
  • .\python -m pip install --no-deps --user scipy

Reluctant to do this in a non-standard fashion, I followed your specific advice and uninstalled Blender, then reinstalled it and finally proceeded with your specific command. But the --user flag would not install it in my Blender site-packages (C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages) … but rather checks for a current installation in my user site-packages (c:\users\me\appdata\roaming\python\python39\site-packages) … as seen here:

C:\WINDOWS\system32> cd C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin
C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin> .\python -m pip install --no-deps --user scipy
Requirement already satisfied: scipy in c:\users\me\appdata\roaming\python\python39\site-packages (1.6.3)

:cry: This is so mysterious for someone who wasn’t born a developer… I wish there was a turnkey command that just works. The above doesn’t. Sure, I could use my former variant, and instead of the --user switch, use the -t flag and forcefully point to my Blender site-packages, but if you say that is a non-standard method, I’d rather want to do this the right way to prevent complications later on. Is there something I can change in order to follow your method?

at least use the right interpreter, with ./python -m xxx with -t option so you will never setup a scipy for python 3.7 over a 3.9 interpreter

The --user option might be the wrong choice in this case, as we want to install it into the “system” version (but that of blender) and not below the user folder.
If my method (with admin console and .\ infront of python.exe) didn’t work then your explicit specification of the target folder is the best we can get.
There might be methods of of installing for an explicit version of python but it is getting messier than it should.

To make sure you use the correct python.exe or at least the correct python version you can run the following python commands with in python.
(again: cd blender_python_dir and .\python.exe

import sys
print(sys.version)      # should print the version used by your blender 
print(sys.executable)   # should the the c:\blender_python_dir\python.exe
import pip
print(pip.__file__)     # should be in the sitepackage folder of blenders python installation

If the version matches then your method is OK. If addionally the sys.executable and even the pip.__fie__ matches then my method should work as well.

I got this:

C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin>.\python
Python 3.9.2 (default, Mar  1 2021, 08:18:55) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.version)
3.9.2 (default, Mar  1 2021, 08:18:55) [MSC v.1916 64 bit (AMD64)]
>>> print(sys.executable)
C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin\python.exe
>>> import pip
>>> print(pip.__file__)
C:\Users\me\AppData\Roaming\Python\Python39\site-packages\pip\__init__.py

What seems odd to me is that it doesn’t appear to use the pip I have in C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages\pip but rather the one I have in my user folder. Is this “normal” or “standard”? If not, can I change that?

That is odd! It’s the blenders site-package for me.
Did you installed or updated pip? ah yes, you mentioned it. Might be the reason but we are getting in areas where i leave the safe shore of my knowledge.

You can look it up online but all in all you seem to use at least the right python.exe. so your method with “-t” should do the right thing for you.

(out of office for today, have a good night :slight_smile: )

1 Like

Oh well. Thank you both, @Tachtian and @stephen_leger for being helpful and coping with a novice nerd like me. Makes me love this community! I’ll will try to investigate things further and see if I can reset pip back to Blender’s site-packages version. Because I upgraded it with some command that I fail to remember which, but that must have changed the used pip.file somehow. Take care friends!