Skip to content
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

Could not find source code file when running in Jupyter lab 3.3.2 #134

Open
zero-jack opened this issue Mar 23, 2022 · 4 comments
Open

Could not find source code file when running in Jupyter lab 3.3.2 #134

zero-jack opened this issue Mar 23, 2022 · 4 comments

Comments

@zero-jack
Copy link

zero-jack commented Mar 23, 2022

Problem

Still getting this error when running %lprun -f take_sqr take_sqr([1,2,3])

Are you sure you are running this program from the same directory
that you ran the profiler from?
Continuing without the function's contents.

ENV

IPython          : 7.32.0
ipykernel        : 6.9.2
ipywidgets       : not installed
jupyter_client   : 7.1.2
jupyter_core     : 4.9.2
jupyter_server   : 1.13.5
jupyterlab       : 3.3.2
nbclient         : 0.5.13
nbconvert        : 6.4.4
nbformat         : 5.2.0
notebook         : 6.4.10
qtconsole        : not installed
traitlets        : 5.1.1

But it's ok when running in iPython.

In [1]: %load_ext line_profiler

In [2]: import numpy as np

In [3]: def take_sqr(array):
   ...:     sqr_ar = [np.sqrt(x) for x in array]
   ...:     return sqr_ar
   ...:

In [4]: %lprun -f take_sqr take_sqr([1,2,3])
Timer unit: 1e-07 s

Total time: 3.1e-05 s
File: <ipython-input-3-e50c1b05a473>
Function: take_sqr at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def take_sqr(array):
     2         1        299.0    299.0     96.5      sqr_ar = [np.sqrt(x) for x in array]
     3         1         11.0     11.0      3.5      return sqr_ar
@Nodd
Copy link
Contributor

Nodd commented Mar 24, 2022

What is your line_profiler version ? You didn't include it in your report.

@zero-jack
Copy link
Author

Updated Information

line-profiler             3.3.0                    pypi_0    pypi
line_profiler             3.4.0            py37hbd76527_1    conda-forge

@Erotemic
Copy link
Member

Seems to work for me:

image

(pyenv3.9.9) joncrall@toothbrush:~$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.1.1
ipykernel        : 6.6.1
ipywidgets       : 7.7.0
jupyter_client   : 7.1.0
jupyter_core     : 4.9.1
jupyter_server   : not installed
jupyterlab       : not installed
nbclient         : 0.5.9
nbconvert        : 6.4.0
nbformat         : 5.1.3
notebook         : 6.4.10
qtconsole        : 5.2.2
traitlets        : 5.1.1

This is with line_profiler 3.5.0

I then upgraded my jupyter packages and got the same correct result:

IPython          : 8.1.1
ipykernel        : 6.10.0
ipywidgets       : 7.7.0
jupyter_client   : 7.1.2
jupyter_core     : 4.9.2
jupyter_server   : 1.15.6
jupyterlab       : 3.3.2
nbclient         : 0.5.13
nbconvert        : 6.4.5
nbformat         : 5.2.0
notebook         : 6.4.10
qtconsole        : 5.2.2
traitlets        : 5.1.1

Maybe try updating your versions? Although if this is an error because of IPython 7.x instead of 8.x we probably should fix it. (can't test that atm).

@zero-jack
Copy link
Author

@Erotemic I confused that I got error running in jupyter lab and why should it upgrade IPython at 8.x? It's ok at IPython at 7.x for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants