I am not able to get the source code of any function in python. Do I need to reinstall python? Does python looks OK in this case?
# python
Python 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 22:25:07)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(arg1,arg2):
... #do something with args
... a = arg1 + arg2
... return a
...
>>> import inspect
>>> lines = inspect.getsource(foo)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/miniforge3/lib/python3.7/inspect.py", line 973, in getsource
lines, lnum = getsourcelines(object)
File "/root/miniforge3/lib/python3.7/inspect.py", line 955, in getsourcelines
lines, lnum = findsource(object)
File "/root/miniforge3/lib/python3.7/inspect.py", line 786, in findsource
raise OSError('could not get source code')
OSError: could not get source code
Update:
Here is the module that I am trying to use and getting the above error:
>>> from marvin import ai_fn
>>> @ai_fn
... @ai_fn
... def rhyme(word: str) -> str:
... "Returns a word that rhymes with the input word."
...
>>> rhyme("blue")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/marvin/bots/ai_functions.py", line 128, in ai_fn_wrapper
return_value = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/marvin/bots/ai_functions.py", line 141, in ai_fn_wrapper
function_def = inspect.cleandoc(inspect.getsource(fn))
File "/usr/local/lib/python3.10/inspect.py", line 1139, in getsource
lines, lnum = getsourcelines(object)
File "/usr/local/lib/python3.10/inspect.py", line 1121, in getsourcelines
lines, lnum = findsource(object)
File "/usr/local/lib/python3.10/inspect.py", line 958, in findsource
raise OSError('could not get source code')
OSError: could not get source code