Please read carefully
this is not about installing packages with Blender's python, but rather their reverse - ignoring system packages.
I DO NOT WANT Blender to use the packages in site-packages
- and all those questions are about how you get to do it.
Also - see at bottom: it seems this started with Python 3.10 (Blender 3.1).
When I try to install packages with pip
I installed under Blender, I get messages such as
Requirement already satisfied: svgpathtools in /home/simone/.local/lib/python3.10/site-packages (1.6.1)
However, Blender's python then doesn't find them when executing scripts.
How do I get Blender's pip to ignore system python's site_packages?
Right now I am working around this by renaming site_packages, but that's horrible and time consuming.
BTW, this seems new to Blender 3.4 (but no guarantee about that).
This is the command I use:
simone$ /home/simone/blender/blender-3.4.1-linux-x64/3.4/python/bin/pip install scikit-learn
and this the output I get:
Requirement already satisfied: scikit-learn in /home/simone/.local/lib/python3.10/site-packages (1.2.1)
Requirement already satisfied: numpy>=1.17.3 in /home/simone/.local/lib/python3.10/site-packages (from scikit-learn) (1.23.5)
Requirement already satisfied: scipy>=1.3.2 in /home/simone/.local/lib/python3.10/site-packages (from scikit-learn) (1.11.1)
Requirement already satisfied: joblib>=1.1.1 in /home/simone/.local/lib/python3.10/site-packages (from scikit-learn) (1.2.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/simone/.local/lib/python3.10/site-packages (from scikit-learn) (3.1.0)
and the same results come if I use
simone$ /home/simone/blender/blender-3.4.1-linux-x64/3.4/python/bin/python3.10 -m pip install scikit-learn
and this is the screenshot of my preferences:
with no trace of extra/strange paths being added in.
I've also recursively looked for the string site-packages
in my .config/blender
directory and found nothing suspicious - except in dream-textures, which I have since deleted - with no result.
Just for kicks, I run this script
import sys
for p in sys.path:
print(p)
on all pythons in all my blender installs. This is the result:
/home/simone/blender/blender-2.93.14-linux-x64/2.93/python/bin/python3.9
/home/simone/blender/blender-2.93.14-linux-x64/2.93/python/lib/python3.9
/home/simone/blender/blender-2.93.14-linux-x64/2.93/python/lib/python3.9/lib-dynload
/home/simone/blender/blender-2.93.14-linux-x64/2.93/python/lib/python3.9/site-packages
/home/simone/blender/blender-2.93.14-linux-x64/2.93/python/lib/python39.zip
/home/simone/blender/blender-3.0.1-linux-x64/3.0/python/bin/python3.9
/home/simone/blender/blender-3.0.1-linux-x64/3.0/python/lib/python3.9
/home/simone/blender/blender-3.0.1-linux-x64/3.0/python/lib/python3.9/lib-dynload
/home/simone/blender/blender-3.0.1-linux-x64/3.0/python/lib/python3.9/site-packages
/home/simone/blender/blender-3.0.1-linux-x64/3.0/python/lib/python39.zip
/home/simone/blender/blender-3.1.2-linux-x64/3.1/python/bin/python3.10
/home/simone/.local/lib/python3.10/site-packages
/home/simone/blender/blender-3.1.2-linux-x64/3.1/python/lib/python3.10
/home/simone/blender/blender-3.1.2-linux-x64/3.1/python/lib/python3.10/lib-dynload
/home/simone/blender/blender-3.1.2-linux-x64/3.1/python/lib/python3.10/site-packages
/home/simone/blender/blender-3.1.2-linux-x64/3.1/python/lib/python310.zip
/home/simone/blender/blender-3.2.0-linux-x64/3.2/python/bin/python3.10
/home/simone/.local/lib/python3.10/site-packages
/home/simone/blender/blender-3.2.0-linux-x64/3.2/python/lib/python3.10
/home/simone/blender/blender-3.2.0-linux-x64/3.2/python/lib/python3.10/lib-dynload
/home/simone/blender/blender-3.2.0-linux-x64/3.2/python/lib/python3.10/site-packages
/home/simone/blender/blender-3.2.0-linux-x64/3.2/python/lib/python310.zip
/home/simone/blender/blender-3.4.1-linux-x64/3.4/python/bin/python3.10
/home/simone/.local/lib/python3.10/site-packages
/home/simone/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10
/home/simone/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/lib-dynload
/home/simone/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/site-packages
/home/simone/blender/blender-3.4.1-linux-x64/3.4/python/lib/python310.zip
/home/simone/blender/blender-3.5.0-linux-x64/3.5/python/bin/python3.10
/home/simone/.local/lib/python3.10/site-packages
/home/simone/blender/blender-3.5.0-linux-x64/3.5/python/lib/python3.10
/home/simone/blender/blender-3.5.0-linux-x64/3.5/python/lib/python3.10/lib-dynload
/home/simone/blender/blender-3.5.0-linux-x64/3.5/python/lib/python3.10/site-packages
/home/simone/blender/blender-3.5.0-linux-x64/3.5/python/lib/python310.zip
So it seems like the lookup in my system Python starts with 3.1. What's going on? how can I stop that? Is there a config variable I messed up by mistake?
unwanted_paths = ['/home/simone/.local/lib/python3.10/site-packages'] sys.path = [p for p in sys.path if p not in unwanted_paths]
in blender 3.1 for example $\endgroup$