1
$\begingroup$

I am currently missing some extra packages in the Python bundled with Blender.

E.g.:

import pyproj Traceback (most recent call last): File "/snap/blender/5374/4.2/python/lib/python3.11/code.py", line 90, in runcode exec(code, self.locals) File "<blender_console>", line 1, in <module> ModuleNotFoundError: No module named 'pyproj' 

whereas in a standalone Python console:

>>> import pyproj >>> pyproj.__version__ '3.6.1' 

This thread is not helping much because to get a cutting-edge Blender version on Ubuntu 22.04+, it has to be installed with snap. Blender install folder is then /snap/blender/5374/4.2/ and everything in that folder is owned by root.

Also, there doesn't seem to be any pip or ensurepip executable in that folder.

Hence my question, how could I install (in the most user friendly way) a Python package which will be installed into the Python embedded with Blender (e.g. probably here: /snap/blender/5374/4.2/python/lib/python3.11/site-packages/) in that specific use case?

If that may be relevant, here are the knows paths in the Blender scripting console:

 import sys for i,j in enumerate(sys.path): print(i,j) 0 /snap/blender/5374/4.2/scripts/startup 1 /snap/blender/5374/4.2/scripts/modules 2 /snap/blender/5374/4.2/python/lib/python311.zip 3 /snap/blender/5374/4.2/python/lib/python3.11 4 /snap/blender/5374/4.2/python/lib/python3.11/lib-dynload 5 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages 6 /snap/blender/5374/4.2/python/lib/python3.11/site-packages 7 /snap/blender/5374/4.2/scripts/freestyle/modules 8 /home/<username>/.config/blender/4.2/scripts/addons/modules 9 /snap/blender/5374/4.2/scripts/addons_core 10 /home/<username>/.config/blender/4.2/scripts/addons 11 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/ifcopenshell/lib/linux/64bit/python3.11 12 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/ifcopenshell/express 13 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 14 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 15 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 16 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 17 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 18 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 19 /home/<username>/.config/blender/4.2/extensions/.local/lib/python3.11/site-packages/odf 

(don't ask me why the last line occurs so many times...)

$\endgroup$
3
  • $\begingroup$ It's definitely a nightmare to install stuff within /snap/ directory... Even with the root user you face the message "Defaulting to user installation because normal site-packages is not writeable". I secretly wish that Blender's dev could upgrade the blender apt package to a higher version than 3.0.x $\endgroup$ Commented Sep 26, 2024 at 10:53
  • $\begingroup$ Hello, have you explored blender.stackexchange.com/questions/5287/… ? $\endgroup$ Commented Sep 26, 2024 at 18:10
  • $\begingroup$ Hi, thanks for the suggestion! I didn't found that post. But from what I can read, it's not about the Blender snap package and there's too much hacks to be run from inside the Python shell which I really want to avoid. Meanwhile, I decided to drop the snap package because it's too rigid and I don't want to mess with mounting points at the OS level. I'm now exploring the installation from the official tarball where I'm having some kind of hope, and my first successes. $\endgroup$ Commented Sep 26, 2024 at 18:34

1 Answer 1

1
$\begingroup$

I've had a lot of problems with modules and dependencies... I'm writing an addon to make this easier on Linux. A little tip for this problem: (Run the following script in a text editor)

import bpy, sys, subprocess your_module = 'pyproj==3.6.1' dir_p = sys.executable install = (f' -m pip install -U {your_module}') command = (dir_p + install) result = subprocess.run(command, shell=True, check=True, capture_output=True, encoding='utf-8') print('FINISHED') 

The last line > every time you reload a user script it adds a line to the path... It also has a solution.

capt

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.