3

I am trying to import the SciPy library inside Blender version 2.8 and I am having trouble. I can import SciPy outside of Blender.

On my system Blender's Python is installed at

 /snap/blender/34/2.81/python

I tried the following answers I found here :

  • As suggested here I tried to install ensurepip inside Blenders Python.
  • I tried to copy the system Python's SciPy folder to Blender's Python site-packages folder.

Both of the solutions are trying to change Blender's python folder -

/snap/blender/34/2.81/python/lib/python3.7/site-packages/

And when I try them, I get stuck with this error :

"Read-only file system"

Remounting the file system doesn't work either, I am wondering if this has something to do with the way Blender 2.8 is installed using snaps?

What can I try next to get SciPy inside Blender?

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
Mn9
  • 31
  • 2
  • 1
    Firstly I don't use snap install of blender so anything to follow is speculative. Am assuming you cannot rename /snap/blender/34/2.81/python either. Try pip install scipy --user to install to a local user folder. As long as the python version of pip matches that of blender, I've found this is perhaps the simplest approach, maybe barring venvs. I have installed matplotlib, scipy, bezier, aubio, gdal and numerous others this way without issue. – batFINGER Dec 26 '19 at 08:57
  • You did not mention what OS you are using. You need to make sure Blender has permissions to write to whatever parts of the file system it has to write during this. On Windows this can be done running Blender as administrator. The code from your link works fine when I test it on Windows starting Blender with Run as administrator. – Martynas Žiemys Dec 26 '19 at 08:58
  • Oops meant to mention using sudo. Personally I would avoid using sudo pip install for the local method. Making the 3rd party libraries available to all. Also forgot to mention plumbum one of my faves. If you can sudo mv (rename) the blender python folder, blender will pick up the matching system python instead. – batFINGER Dec 26 '19 at 09:04
  • Alternatively if you set up a virtual environment using your blender python (or matching system python) set the following environment variables https://docs.blender.org/manual/en/dev/advanced/command_line/arguments.html#environment-variables @RobertGützkow let's say "another" approach. – batFINGER Dec 26 '19 at 09:12
  • 1
    @batFINGER that would be even better, venvs are the cleanest approach in my opinion until the user packages dir for Blender is used (see T71420). – Robert Gützkow Dec 26 '19 at 09:56
  • @batFINGER If I use the --user option the modules are installed under ~/.local/lib/python3.7/site-packages. Is there any way to tell Blender to use site-packages stored under that location? – TheBeautifulOrc Sep 15 '20 at 12:58
  • @TheBeautifulOrc its appended to my sys.path by default in site.py or in cmake can't remember.... . Building blender so quite likely this is not standard. Appending it to your sys.path will have the desired result. – batFINGER Sep 15 '20 at 13:10
  • @batFINGER I don't really understand what you mean with "appending it to my sys.path"... – TheBeautifulOrc Sep 15 '20 at 13:34

0 Answers0