External python module ?

I need a module call

but blender does not have it !

now I already have python 3.4 installed on my system

where can I install this new module and how to use it in blender ?

this seems to come as an egg file
what do you do with that ?

thanks

Do you have ‘pip’ installed? If so you can grab it and put it into the same directory as your .blend file or into your ‘addon’ directory. There is lots of documentation around for where to install modules so that Blender’s python can pick them up.

pip install --target <directory_for_module> <pytz_URL>

For example:
pip install --target /usr/tmp <pytz_URL>

Would create a directory called “/usr/tmp/pytz”

I got it for ipython
but wondering if necessary to install it in blender

anyway to import it from the 3.4 python on my system instead ?

if possible don’t wont to have to re instal it each time we change over build
or running it from a local build !

there is a way to add a new path in a script
but can it be use for importing a module from python system?

thanks

There are ways to do it. You should read up on how Python searches for modules https://docs.python.org/2/tutorial/modules.html#the-module-search-path.

Blender has some more complexities with how it interact with Python because it bundles a copy of Python with Blender instead of using an existing Python install on the system. I have always put my modules next the the .blend file that needed them so I’ve never really looked deeply into how to control the module search path.

My gut says that getting Blender to pull in modules from a system Python install will require some work-arounds.

This works for me:

import sys 
sys.path.append("E:\Python34\Lib\site-packages") 
import __yourmodule__

Replace the directory path to wherever your python installation is. I think this is more portable than copying the module into blender’s python directory, since you can run it from any blender version and the same code will work.

1 Like

I have my own scripts folder (next to my art, in version control) that contains my plugins.
In user preferences i have pointed blender to that folder as scripts folder.

Here’s my setup:


scripts/
  - modules/
    - mysql
    - other modules
  - addons/
    - addon1
    - addon2...

From my addons I can now just import mysql and the other modules I have in ‘modules’

derGoldstein, I’m a newbie trying to import some python modules. I’m on my 3rd day. I had high hopes for your solution.

My python is ‘C:\Python34’ and I’ve installed PIL.
From pyCharm the code

from PIL import Image #works great

inside Blender

import sys
sys.path.append(“C:\Python34\Lib\site-packages”)
from PIL import Image

gets the error:
File “C:\Python34\Lib\site-packages\PIL\Image.py”, line 63, in <module>
from PIL import _imaging as core
ImportError: DLL load failed: %1 is not a valid Win32 application.

You had said ‘Replace the directory path to wherever your python installation is.’ How would I do that?
and might that fix my problem?
thanks - kurt

kklinzing:
I can think of two things:

  1. import the entire module (“import PIL”) rather than using “from X import Y”
  2. Try importing another module. Find something that the Blender installation of python doesn’t have and import that. If that doesn’t work at least you know that it’s the importing process that doesn’t work.

In case anyone is wondering: You’re not supposed to use the discontinued PIL, and rather the “Pillow” library which is a compatible replacement, licensed more flexible and still maintained!

It’s also a great candidate for inclusion in the standard blender distributions for obvious reasons.