-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ic Error: Failed to access the underlying source code for analysis. #79
Comments
Probably a duplicate of #68 Really need to fix that README and error message. If you didn't try it in the shell, what did you do? The error message is completely generic. |
I just run Python code using Pytorch and asked for |
Still need more detail than that. Can you provide a script and instructions to reproduce? |
I am terribly sorry, I really cant reproduce it now. Now, after few more tries, I see this package is stable. I cant reproduce the problem. |
@rnoxy did the underlying source code change while the code was running? your editor could have saved a change even though you didn't agreed @alexmojaki: changing the error message |
Version: 1.65.2 (system setup) from icecream import ic def foo(i): ic(foo(123)) ic| Error: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution? Would love to use this module but it keeps getting this error. |
It took me a while to figure out that this was a VS Code version. What version of Python are you using? How did you run the script? |
I'm getting this error with Python 3.11.0b3. The same script I'm running works fine with Python 3.9. Have you tried 3.11 yet? It seems like something might have changed in the introspection. |
Yes, the underlying introspection doesn't work yet in 3.11, but it's getting close: alexmojaki/executing#31 |
Ok. Thanks @alexmojaki |
@alexmojaki: awesome @ alexmojaki/executing#31! 🙌 any estimate of when py3.11 support will land in executing? if not for a week+, ill add a note to icecream's readme that py3.11 isnt supported just yet 🙂 |
I would say not for a week+ |
sweet. i just added a quick note to the readme that py3.11 support is forthcoming ill remove that note once alexmojaki/executing#31 lands 🙌 |
My first attempt with icecream gave this error. Some information that may be useful:
|
Could it be that 3.11 is still not working ? |
3.11 should be working now. @rafaelcesar0 were you using a Python shell/REPL or did you run a |
I cannot confirm this at all. It works under 3.10 running from PyCharm, but not with 3.11. I see a similar error was logged just 16 hours ago by @rafaelcesar0 |
|
I believe the Python shell/REPL. I was using powershell7 in vscode with the "Run Python file" command from the Python extension @alexmojaki |
I'm having the same error running a program under Python 3.11.4 in a venv under VSCode with icecream-2.1.3. Works great with Python 3.9.6 in a different venv. |
I started it using with python 3.12.0 Conda. It wasn't giving me the error with other versions.-in VS code |
trying to print np.array and torch.tensor results in error message: script to reproduce:
output from script on my machine:
|
numpy and pytorch shouldn't be relevant. The version of import inspect
import sys
import platform
import executing
print(sys.version)
print(executing.__version__)
print(platform.platform())
ex = executing.Source.executing(inspect.currentframe())
print(ex.source.lines)
print(ex.statements)
print(ex.node) |
Hello! Just landed in this page after getting the OP's error. Here's the output: In [1]: import inspect
...: import sys
...: import platform
...:
...: import executing
...:
...: print(sys.version)
...: print(executing.__version__)
...: print(platform.platform())
...:
...: ex = executing.Source.executing(inspect.currentframe())
...: print(ex.source.lines)
...: print(ex.statements)
...: print(ex.node)
3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ]
0.8.3
macOS-14.0-arm64-arm-64bit
['import inspect', 'import sys', 'import platform', '', 'import executing', '', 'print(sys.version)', 'print(executing.__version__)', 'print(platform.platform())', '', 'ex = executing.Source.executing(inspect.currentframe())', 'print(ex.source.lines)', 'print(ex.statements)', 'print(ex.node)']
{<ast.Assign object at 0x105dc5720>}
None |
You can see what the latest version of executing is here: https://pypi.org/project/executing/ |
I'm not sure whether this is a reply to me. I see that the last version is 2.0.1. I just created a Conda environment with Line 104 in fc40981
Would it be a good idea to use a more recent lower bound for the version of |
I have same problem inside py2exe |
Same issue on python 3.11.5, appears when running in the Spyder ipython console and when calling a script from the terminal.
Output:
|
It seems that conda or something packages an old version of executing for reasons I don't understand. executing is a dependency of IPython, but it has a conda package that's up to date. I don't use conda myself. If someone could report an issue in the appropriate place that would be really helpful. |
What version of Where would you like this to be reported? Thanks |
1.0.0 is needed to fix a problem that often affects IPython users, hence this problem is bigger than icecream. I don't know where to report the issue or how to construct a good report, I don't use conda. 1.1.0 is needed for Python 3.11, hence the reports here. 2.0.1 is needed for Python 3.12. Increasing the minimum version of executing here would be good, but it needs to be per Python version because 2.0.1 doesn't support Python 2. A PR would be appreciated. |
|
I am on Python 3.12, icecream 2.13 and executing 2.0.1 and I'm getting this issue. |
Please run this script and share the output: import inspect
import sys
import platform
import executing
print(sys.version)
print(executing.__version__)
print(platform.platform())
ex = executing.Source.executing(inspect.currentframe())
print(ex.source.lines)
print(ex.statements)
print(ex.node) |
##Code: `from icecream import ic def foo(i): ic(foo(123))` returns: ic| Error: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution? Result of your 'debug' code above: 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] |
Fixed the issue for me too, but I'm not sure about the ripple effect ! |
I was getting the same error reported by others. In my Anaconda I had executing 0.8.3 and I didn't managed to update it in any way. I ended up using |
I installed icecream using: This ensures I get both latest versions of ic and executing. It worked for me with python 3.12. |
I get this output: I'm running in a juypter notebook using dataspell |
I’m also experiencing this sometimes in the Juno iOS app |
The issue is still very much live. On Linux-aarch64-glibc2.31 REPL:
On Windows-10-10.0.19045-SP0 REPL:
Failing combinations report: >>> print(ex.source.lines)
[]
>>> print(ex.statements)
set()
>>> print(ex.node)
None On working Python 3.13: >>> print(ex.source.lines)
['ex = executing.Source.executing(inspect.currentframe())']
>>> print(ex.statements)
{<ast.Assign object at 0x0000022BC08B6250>}
>>> print(ex.node)
None Reproduction code: >>> from icecream import ic
>>> d = {'abc': 111, 'ghi': 333, 'def': 222}
>>> print(d)
{'abc': 111, 'ghi': 333, 'def': 222}
>>> ic(d)
ic| Error: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution?
{'abc': 111, 'ghi': 333, 'def': 222} |
|
Yes, I went all debug log instead of saying what my issue is: why is there an error in REPL at all? It could be just pretty-printed as fallback, surely? And again it's fine in 3.13, so that adds to my confusion. |
The error is
This is a fair point which could be a new issue.
The fact that source code is now available in the REPL in 3.13 is very exciting news. |
I tried all the possible solutions that you published and in my case none of them worked, these are the errors and my equipment configuration, i have the same isuue in terminal and in Pycharm ic| Error: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution? This the result of the script
(base) gatito@gatito-All-Series:~$ conda env list conda environments:base * /home/gatito/anaconda3 (base) gatito@gatito-All-Series:
Package Planenvironment location: /home/gatito/anaconda3 added / updated specs: The following packages will be downloaded:
The following NEW packages will be INSTALLED: executing pkgs/main/noarch::executing-0.8.3-pyhd3eb1b0_0 The following packages will be UPDATED: certifi 2024.7.4-py312h06a4308_0 --> 2024.8.30-py312h06a4308_0 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done
KeyboardInterrupt
Package Planenvironment location: /home/gatito/anaconda3 added / updated specs: The following NEW packages will be INSTALLED: executing pkgs/main/noarch::executing-0.8.3-pyhd3eb1b0_0 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done
Package Planenvironment location: /home/gatito/anaconda3 added / updated specs: The following packages will be downloaded:
The following packages will be UPDATED: executing pkgs/main::executing-0.8.3-pyhd3eb1b0~ --> conda-forge::executing-2.1.0-pyhd8ed1ab_0 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done
this the result of the script
|
Problem solved, I had already given up on using icecream, initially I detected the problem when trying to use ic in pycharm, then all the tests I did, I did them from a terminal outside of pycharm, I posted my previous comment, and when I return to pycharm and run my program with ic (to find & change the lines with ic ), the program worked without any problem, at some point with the solutions I tried, corrected the problem, I write this so someone else can find the real solution. ic| f": ("Models in whisper: ['tiny.en', 'tiny', 'base.en', 'base', " |
That was in a REPL, i.e. the interactive shell. |
My first try with icecream (Python 3.8)
The text was updated successfully, but these errors were encountered: