Open QQQQQQinyan opened 3 years ago
Coule be fixed when install the pyreadline package
In windows, dive into the python folder of the installation directory of Houdini.
python -m pip install pyreadline
However, it print into the Houdini Console instead of the python shell
Hi @QQQQQQinyan This issue is pretty complicated: Taichi use custom source inspect module to locate the python file, and build AST from the file, however, it's hard to locate code written in Python SOP or houdini python shell, since we have no idea what houdini does to code in its shell.
So, alternative to this,
You‘d better write your taichi-scope function/kernel into a .py file, like this https://github.com/taichi-dev/taichi_houdini/blob/master/Libs/python/fractal.py, and put it into somewhere like package/scripts/python so you could import it into houdini, and then import this module and call it inside houdini python shell or python sop.
Hope that answer your question!
yes, got it, Thanks~
It shows errors when I run a function made in Houdini python shell
Errors: Traceback (most recent call last): File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it__.py", line 150, in our_findsource return inspect._si_old_findsource(object) File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.696\python37\lib\inspect.py", line 786, in fin dsource raise OSError('could not get source code') OSError: could not get source code
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it__.py", line 96, in blender_findsourcetext import bpy ModuleNotFoundError: No module named 'bpy'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it.py", line 153, in our_findsource return blender_findsource(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it__.py", line 110, in blender_findsource lines, text_name = blender_findsourcetext(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect\in it__.py", line 98, in blender_findsourcetext raise IOError('Not in Blender environment!') OSError: Not in Blender environment!
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it.py", line 156, in our_findsource return remote_findsource(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect\in it.py", line 42, in remote_findsource lines = remote_findsourcelines(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect\in it__.py", line 28, in remote_findsourcelines raise IOError(f'Cannot find file {file}!' + message) OSError: Cannot find file C:\Users\ps\AppData\Local\Temp\houdini_temp\SI_IPC_10700.p y! To make Taichi functional in IDLE, please append the following line:
import("sourceinspect").remote_hack(globals())
to file "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.696\python37\lib\code.py".
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in it.py", line 159, in our_findsource return dill_findsource(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect\in it__.py", line 145, in dill_findsource return dill.source.findsource(object) File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\dill\source.py", l ine 129, in findsource raise IOError(err) OSError: No module named 'readline', please install 'pyreadline'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\taichi\lang\kernel
_impl.py", line 669, in wrapped
return primal(*args, *kwargs)
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\taichi\lang\shell.
py", line 40, in new_call
ret = old_call(args, *kwargs)
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\taichi\lang\kernel
_impl.py", line 596, in call
key = self.ensure_compiled(args)
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\taichi\lang\kernel
_impl.py", line 587, in ensure_compiled
self.materialize(key=key, args=args, arg_features=arg_features)
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\taichi\lang\kernel
_impl.py", line 395, in materialize
src = _remove_indent(oinspect.getsource(self.func))
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect__in
it.py", line 185, in getsource
return inspect.getsource(object)
File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.696\python37\lib\inspect.py", line 973, in get
source
lines, lnum = getsourcelines(object)
File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.696\python37\lib\inspect.py", line 955, in get
sourcelines
lines, lnum = findsource(object)
File "C:\Users\ps\AppData\Roaming\Python\Python37\site-packages\sourceinspect\in
it__.py", line 161, in our_findsource
raise IOError(f'Could not get source code for object: {repr(object)}')
OSError: Could not get source code for object: <function foo at 0x00000000EE4DF288>