What I am trying to do

Trying to run python modules such as osgeo(GDAL), and others in blender. These modules have been installed on the system python environment using pip.

Things i have tried

Deleting blender python environment

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encoding'

Tried symlinking system python to replace blender python

Tried copying python libraries into blender libraries

Tried both python3.5 and python3.6 - i believe blender uses 3.6

What happens

Regardless of my attempts i get either the module cannot be found or python locale error

Other Information

I am running CentOS 7. Blender 2.78c from binaries x64(blender.org).

What doesn't makes sense to me is when I install on ubuntu using ppa I don't have this issue. I am trying to avoid compiling from source if possible for reason i am not going to get into here.

Any help is appreciated.


Installing Pip into blender environment

Pip now working in blenders python environment. gdal fails to compile with gcc error importing Python.h

Successfully symlinked system python to blender python:

/usr/lib/blender/2.78/python/bin/python3.5m  --> /usr/bin/python3.5m

Blender now runs off system python environment but still does not see gdal

If i run /usr/bin/python3.5m --> import osgeo : it works

If i run /usr/lib/blender/2.78/python/bin/python3.5m --> import osgeo : fails to import


1 Answer 1


If you can, install from system repositories. I've heard that CentOS's isn't very good at this, and on Windows you can't, so here are some other solutions.

The first thing to try is deleting the python folder from the blender install. (you don't need to symlink it, remove it entirely) This should make it use the system python.

The next thing to try is to install pip inside blender. This isn't too hard to do, and is useful in many other cases (eg want a portable version of blender with a specific module)

  1. Download get-pip.py and rename it to get_pip.py
  2. Start blender's python runtime (inside blender/2.78/python/bin/) and run the executable (python3.5m on linux 2.78c) from a terminal.
  3. Add your download folder to the path so python can find get_pip. Do this with: import sys sys.path.append('~/Downloads') # Change path as required
  4. Now you should be able to import get_pip, and run get_pip.main().
  5. Then, to install things, you can use: import pip pip.main(['install', 'osgeo'])

You could try it from blender's built in console, but on the windows version this does funny things (like opening lots of instances of blender!), so I haven't gone into detail.

  • $\begingroup$ CentOS repos are terrible. The newest version in repos is 2.68 that I can find. I have already tried deleting blenders python environment and get a python error. I will update question when I get home with specific error message. I will try the pip suggestion also. Thank you for your suggestions. $\endgroup$
    – Chris
    Commented Jun 23, 2017 at 17:44
  • $\begingroup$ So I tried your suggestion. I got pip working in the blender python environment. However gdal fails to install referencing various libraries missing from python-devel. I have this installed for all the versions of python installed on the system but since this is not part of those environments i cannot install it for this. Not sure where to go from here. Any other suggestions would be appreciated $\endgroup$
    – Chris
    Commented Jun 25, 2017 at 6:05
  • $\begingroup$ I'm afraid I haven't come across this issue. You could try copying the necessary libraries from /lib64/python3.6 into blender/2.78/python/lib/python3.6 Also check inside the site-packages subdirectory - this is where pip puts things. $\endgroup$
    – sdfgeoff
    Commented Jun 25, 2017 at 8:08
  • $\begingroup$ Thanks for your suggestions. I'll keep playing around until I figure it out. $\endgroup$
    – Chris
    Commented Jun 26, 2017 at 5:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .