0
OSError: Could not get source code -Pydroid
I was just testing the inspect.getsource to see that it works or not. I wrote the following code in pydroid- import inspect def Test (): print ("Hi") print(inspect.getsource(Test)) --------------------------- It gave a long traceback(I will write in an answer because it is too long to show here)
4 Réponses
+ 1
Then it may be due to the working of pydroid. Maybe when you run a file from pydroid it runs it in a interactive mode instead of running it as a file. As inspect module wil not work as expected in interactive mode.
Jan can you help him, I think you are currently using pydroid (if I am not wrong)
+ 1
The traceback:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 4, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/inspect.py", line 992, in getsource
lines, lnum = getsourcelines(object)
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/inspect.py", line 974, in getsourcelines
lines, lnum = findsource(object)
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/inspect.py", line 805, in findsource
raise OSError('could not get source code')
OSError: could not get source code
[Program finished]
+ 1
Have you saved your file before running it?
+ 1
AKSHAY [less active] Yes it is saved