spyder-ide/spyder-line-profiler

spyder-line-profiler not completely installed

KevinNadar opened this issue ยท 15 comments

After installing spyder-line-profiler from conda, it is asking me to install the line_profiler (via pip because it is not available via conda). image

But shouldn't I mix pip and conda?

Anyways the github page for it says that it's current version(v2.1.2) is broken for now and we have to follow a different set of commands.

What should I do?

  • Spyder version: 5.3.1 None
  • Python version: 3.9.13 64-bit
  • Qt version: 5.15.3
  • PyQt5 version: 5.15.4
  • Operating System: Linux 5.18.3-arch1-1

Mandatory:

atomicwrites >=1.2.0 : 1.4.0 (OK)
chardet >=2.0.0 : 4.0.0 (OK)
cloudpickle >=0.5.0 : 2.1.0 (OK)
cookiecutter >=1.6.0 : 2.1.1 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree >=3.0.2 : 3.0.2 (OK)
IPython >=7.31.1;<8.0.0 : 7.33.0 (OK)
jedi >=0.17.2;<0.19.0 : 0.18.1 (OK)
jellyfish >=0.7 : 0.9.0 (OK)
jsonschema >=3.2.0 : 4.6.0 (OK)
keyring >=17.0.0 : 23.6.0 (OK)
nbconvert >=4.0 : 6.5.0 (OK)
numpydoc >=0.6.0 : 1.4.0 (OK)
parso >=0.7.0;<0.9.0 : 0.8.3 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=5.3 : 5.9.1 (OK)
pygments >=2.0 : 2.12.0 (OK)
pylint >=2.5.0 : 2.14.1 (OK)
pyls_spyder >=0.4.0 : 0.4.0 (OK)
pylsp >=1.4.1;<1.5.0 : 1.4.1 (OK)
pylsp_black >=1.2.0 : 1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0 : 3.0.3 (OK)
qstylizer >=0.1.10 : 0.2.1 (OK)
qtawesome >=1.0.2 : 1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0 : 5.3.1 (OK)
qtpy >=2.1.0 : 2.1.0 (OK)
rtree >=0.9.7 : 1.0.0 (OK)
setuptools >=49.6.0 : 62.3.4 (OK)
sphinx >=0.6.6 : 5.0.1 (OK)
spyder_kernels >=2.3.1;<2.4.0 : 2.3.1 (OK)
textdistance >=4.2.0 : 4.2.2 (OK)
three_merge >=0.1.1 : 0.1.1 (OK)
watchdog >=0.10.3 : 2.1.9 (OK)
xdg >=0.26 : 0.28 (OK)
zmq >=22.1.0 : 23.1.0 (OK)

Optional:

cython >=0.21 : 0.29.30 (OK)
matplotlib >=3.0.0 : 3.5.2 (OK)
numpy >=1.7 : 1.22.4 (OK)
pandas >=1.1.1 : 1.4.2 (OK)
scipy >=0.17.0 : 1.8.1 (OK)
sympy >=0.7.3 : 1.10.1 (OK)

Spyder plugins:

spyder_line_profiler.spyder.plugin 0.3.0 : 0.3.0 (OK)
spyder_terminal.terminalplugin 1.2.2 : 1.2.2 (OK)

Hi @KevinNadar thank you for the feedback! Could you try to manually install line_profiler from conda-forge using conda install -c conda-forge line_profiler? As you say you shouldn't mix pip and conda normally

Checking locally when installing spyder-line-profiler with conda (conda-forge) I'm also being prompt to install line_profiler (I'm checking this with Windows and Python 3.7 though)

imagen

However, I think we should update the link shown in the message you got since the current repo where line_profiler is being mantained is https://github.com/pyutils/line_profiler instead of the old one http://pythonhosted.org/line_profiler/ -> https://github.com/rkern/line_profiler

Let us know if something of the above helps!

Checking locally when installing spyder-line-profiler with conda (conda-forge) I'm also being prompt to install line_profiler (I'm checking this with Windows and Python 3.7 though)

@dalthviz, what does this mean? Are we not validating correctly that line_profiler is installed?

I realized I had tried earlier to install line-profiler instead of line_profiler via conda
The package is named as line-profiler in pip and line_profiler in conda

I was able to install the package๐Ÿ‘‡๐Ÿพ...
Screenshot_~ : fish_12
I entered y and then the transaction was successfull, but then when I restarted Spyder, It is the same as before...

I can confirm that it is installed as it was listed in the output of the conda list command...

The plugin/spyder is unable to detect it...

PS: Why didn't the line_profiler module get installed when I had originally installed spyder-line-profiler ๐Ÿค”

@dalthviz, what does this mean? Are we not validating correctly that line_profiler is installed?

In my case, as seen in the Anaconda prompt screenshot, when installing spyder-line-profiler I got installed line_profiler too (maybe the I'm also being prompt to install ... phrasing was confusing since could imply that I reproduced this but to be clear I was unable to reproduce this).

Maybe is something related with the line_profiler package on Linux? Checking the conda recipe the requirement is there:

https://github.com/conda-forge/spyder-line-profiler-feedstock/blob/cba8d9e85d9e86c19b8fd6e1a8e7f317b1456c1a/recipe/meta.yaml#L26-L30

I can confirm that it is installed as it was listed in the output of the conda list command...

The plugin/spyder is unable to detect it...

PS: Why didn't the line_profiler module get installed when I had originally installed spyder-line-profiler ๐Ÿค”

๐Ÿค” seems like we will need to check this on Linux specifilly. Just in case, could you try to force a reinstall of the plugin to check if that helps @KevinNadar ? Let us know!

thinking seems like we will need to check this on Linux specifilly. Just in case, could you try to force a reinstall of the plugin to check if that helps @KevinNadar ? Let us know!

It worked!!

Thanks ๐Ÿ‘๐Ÿพ

Uhmm...
It worked fine yesterday when I tested it...
But today when I reopened Spyder...It is back to square one...

Screenshot_20210331
I opened up the Internal Console pane to check for errors, but it showing some errors related to spyder-terminal instead...

PS: I am doing all this in a different conda environment(not base) containing all conda-forge channel packages...


Conda info

active environment : spyder-conda-forge
active env location : /home/kevin/anaconda3/envs/spyder-conda-forge
shell level : 1
user config file : /home/kevin/.condarc
populated config files : /home/kevin/.condarc
conda version : 4.13.0
conda-build version : 3.21.9
python version : 3.9.12.final.0
virtual packages : __linux=5.18.3=0
__glibc=2.35=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/kevin/anaconda3  (writable)
conda av data dir : /home/kevin/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/kevin/anaconda3/pkgs
/home/kevin/.conda/pkgs
envs directories : /home/kevin/anaconda3/envs
/home/kevin/.conda/envs
platform : linux-64
user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.18.3-arch1-1 garuda/Soaring glibc/2.35
UID:GID : 1000:1001
netrc file : /home/kevin/.netrc
offline mode : False

# conda environments:
#
base                     /home/kevin/anaconda3
spyder-conda-forge    *  /home/kevin/anaconda3/envs/spyder-conda-forge

sys.version: 3.9.12 (main, Jun  1 2022, 11:38:51)
[G...
sys.prefix: /home/kevin/anaconda3
sys.executable: /home/kevin/anaconda3/bin/python
conda location: /home/kevin/anaconda3/lib/python3.9/site-packages/conda
conda-build: /home/kevin/anaconda3/bin/conda-build
conda-content-trust: /home/kevin/anaconda3/bin/conda-content-trust
conda-convert: /home/kevin/anaconda3/bin/conda-convert
conda-debug: /home/kevin/anaconda3/bin/conda-debug
conda-develop: /home/kevin/anaconda3/bin/conda-develop
conda-env: /home/kevin/anaconda3/bin/conda-env
conda-index: /home/kevin/anaconda3/bin/conda-index
conda-inspect: /home/kevin/anaconda3/bin/conda-inspect
conda-metapackage: /home/kevin/anaconda3/bin/conda-metapackage
conda-pack: /home/kevin/anaconda3/bin/conda-pack
conda-render: /home/kevin/anaconda3/bin/conda-render
conda-repo: /home/kevin/anaconda3/bin/conda-repo
conda-server: /home/kevin/anaconda3/bin/conda-server
conda-skeleton: /home/kevin/anaconda3/bin/conda-skeleton
conda-token: /home/kevin/anaconda3/bin/conda-token
conda-verify: /home/kevin/anaconda3/bin/conda-verify
user site dirs:

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: spyder-conda-forge
CONDA_PREFIX: /home/kevin/anaconda3/envs/spyder-conda-forge
CONDA_PROMPT_MODIFIER: (spyder-conda-forge)
CONDA_PYTHON_EXE: /home/kevin/anaconda3/bin/python
CONDA_ROOT: /home/kevin/anaconda3
CONDA_SHLVL: 1
CURL_CA_BUNDLE: <not set>
PATH: /home/kevin/anaconda3/envs/spyder-conda-forge/bin:/home/kevin/.cargo/bin:/home/kevin/.spicetify:/home/kevin/anaconda3/condabin:/home/kevin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
UBUNTU_MENUPROXY: <set>
XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0
XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session0

Quite strange @KevinNadar , regarding the messages you got from spyder-terminal they are not harmful (they appear when starting the spyder terminal plugin and I think there is an issue already regarding that at spyder-ide/spyder-terminal#327). Regarding the line_profiler installation, are you able to import line_profiler from the Internal Console? Maybe for some reason that is failling inside the plugin so even if you have the package installed it is being detected as not installed ๐Ÿค”

I ran the command import line_profiler in the internal console but nothing happened...
I tried closing and re-opening the plugin pane but it's still the same...

Just in case that's the function that does the validation that seems like is failling for you (even when you have line_profiler installed) is at:

def is_lineprofiler_installed():
"""
Check if the program and the library for line_profiler is installed.
"""
return (programs.is_module_installed('line_profiler')
and programs.find_program('kernprof') is not None)

Could you run from the internal console the following:

from spyder_line_profiler.spyder.widgets import is_lineprofiler_installed
is_lineprofiler_installed()

from spyder.utils import programs
programs.is_module_installed('line_profiler')
programs.find_program('kernprof')

Maybe with that we can get what is the missing thing. Let us know!

I have submitted the output, now what to do?

Thanks @KevinNadar for the new info. Seems then like the problem comes from kernprof not being available/detected. I think this could be either an issue with the conda-forge line_profiler on Linux or the way we are detecting programs on Spyder. Just to be sure, if you run from the internal console kernprof the command exists? What happens if you try to run it from a terminal with the env you are using activated? Let us know!

The command kernprof resulted in module not found error... but when I import it by import kernprof, it was imported...

When I ran kernprof from the command line after activating the appropriate environment, it runs...

Screenshot_20210353

๐Ÿค” thanks for the new info @KevinNadar

@ccordoba12 could something be happening with the Spyder running env activation to not be able to detected entrypoints from packages on Linux?

After PR #78, we are no longer using the kernprof entrypoint but instead running python -m kernprof so I think that should solve this issue, as import kernprof did work.