[Bf-python] Interfacing Blender with IPython

Campbell Barton ideasman42 at gmail.com
Fri Jun 29 09:57:27 CEST 2012


On Fri, Jun 29, 2012 at 9:27 AM, klo uo <klonuo at gmail.com> wrote:
> On Thu, Jun 28, 2012 at 6:17 PM, Campbell Barton wrote:
>> There is nothing special about my build environment, stock ubuntu
>> 12.04 and arch linux - I've done this many times with bpython and
>> ipython, with old blender 2.4x, the game engine and more recently with
>> py3. this always worked fine.
>>
>> Could you try this on a recent build? - if there is some crash it
>> would be good to get a backtrace.
>
> OK, here is what I got on Ubuntu 12.04 32bit with 3 different Blender versions:
>
> 1. Any Blender version and IPython 0.12.1 installed from Ubuntu repositories:
>
>  | >>> import sys
>  | >>> sys.path
>  | ['/usr/lib/blender/scripts/addons',
> '/usr/lib/blender/scripts/startup',
> '/usr/lib/blender/scripts/modules', '/usr/lib/python3.2/',
> '/usr/lib/python3.2/plat-linux2', '/usr/lib/python3.2/lib-dynload',
> '/usr/lib/blender/scripts/addons/modules']
>  |
>  | >>> sys.path.append('/usr/lib/python3/dist-packages')
>  | >>> from IPython import embed
>  | Traceback (most recent call last):
>  |   File "<blender_console>", line 1, in <module>
>  |   File "/usr/lib/python3/dist-packages/IPython/__init__.py", line
> 43, in <module>
>  |     from .config.loader import Config
>  |   File "/usr/lib/python3/dist-packages/IPython/config/loader.py",
> line 27, in <module>
>  |     from IPython.utils.path import filefind, get_ipython_dir
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/path.py",
> line 24, in <module>
>  |     from IPython.utils.process import system
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/process.py",
> line 27, in <module>
>  |     from ._process_posix import _find_cmd, system, getoutput, arg_split
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/_process_posix.py",
> line 27, in <module>
>  |     from IPython.utils import text
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/text.py",
> line 30, in <module>
>  |     from IPython.utils.io import nlprint
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/io.py", line
> 90, in <module>
>  |     stdin = IOStream(sys.stdin)
>  |   File "/usr/lib/python3/dist-packages/IPython/utils/io.py", line
> 32, in __init__
>  |     raise ValueError("fallback required, but not specified")
>  | ValueError: fallback required, but not specified
>
>
> 2. Blender 2.62-1 from Ubuntu repository and IPython 0.13dev (compiled
> git version):
>
>  | >>> import sys
>  | >>> sys.path.append('/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg')
>  | >>> from IPython import embed
>  | >>> embed()
>
>  - CPU maxed, memory pumping, with no output in terminal from which
> Blender was started (also I tried various Blender debug switches -
> it's same). This is the same as with my svn Blender compile
>
>
> 3. Blender-2.63a-linux-glibc27-i686 from blender.org and IPython
> 0.13dev (compiled git version):
>
>  | >>> import sys
>  | >>> sys.path.append('/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg')
>  | >>> from IPython import embed
>  | >>> embed()
>  | Traceback (most recent call last):
>  |   File "<blender_console>", line 1, in <module>
>  |   File "/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg/IPython/frontend/terminal/embed.py",
> line 282, in embed
>  |     _embedded_shell = InteractiveShellEmbed(**kwargs)
>  |   File "/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg/IPython/frontend/terminal/embed.py",
> line 97, in __init__
>  |     display_banner=display_banner
>  |   File "/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg/IPython/frontend/terminal/interactiveshell.py",
> line 317, in __init__
>  |     user_module=user_module, custom_exceptions=custom_exceptions
>  |   File "/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg/IPython/core/interactiveshell.py",
> line 452, in __init__
>  |     self.init_user_ns()
>  |   File "/home/klo/.local/lib/python3.2/site-packages/ipython-0.13.beta1-py3.2.egg/IPython/core/interactiveshell.py",
> line 1122, in init_user_ns
>  |     from site import _Helper
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/site.py",
> line 529, in <module>
>  |     main()
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/site.py",
> line 517, in main
>  |     known_paths = addusersitepackages(known_paths)
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/site.py",
> line 263, in addusersitepackages
>  |     user_site = getusersitepackages()
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/site.py",
> line 238, in getusersitepackages
>  |     user_base = getuserbase() # this will also set USER_BASE
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/site.py",
> line 228, in getuserbase
>  |     USER_BASE = get_config_var('userbase')
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/sysconfig.py",
> line 577, in get_config_var
>  |     return get_config_vars().get(name)
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/sysconfig.py",
> line 474, in get_config_vars
>  |     _init_posix(_CONFIG_VARS)
>  |   File "/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/sysconfig.py",
> line 339, in _init_posix
>  |     raise IOError(msg)
>  | IOError: invalid Python installation: unable to open
> /home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python/lib/python3.2/config-3.2mu/Makefile
> (No such file or directory)
>
>
> So I don't know what other combination to try, but probably you were
> using some other version of both software?

Somehow you have blender's python module bundling its own python
installation, this shouldn't happen ever,
CMake even checks for this case and disallows:

if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
	message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL
to be OFF")
endif()

Probably you built blender normally, installed python into blenders
dir, then rebuilt as a module... even in this case it should not use
blenders bundled python, but somehow it looks like its trying to.

remove:
/home/klo/Downloads/blender-2.63a-linux-glibc27-i686/2.63/python

and it should work ok.



More information about the Bf-python mailing list