This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Cantor and Python backend -- different from shell python

Tags: None
(comma "," separated)
stwerp
Registered Member
Posts
1
Karma
0
I saw a recent KDE blogpost, and decided to try Cantor as an interface for jupyter notebooks.

The main issue I noticed was that I couldn't import packages (numpy, matplotlib) that I know work when I invoke python from a shell.

I had trouble with the snaps and flatpaks, and figured this had to do with sandboxing, as I still don't quite understand what these (snap/flatpak) actually do. So I've gone back to the binary packages on my distribution repos.

On a computer with Kubuntu 22.04, I was able to install the cantor package and then the cantor-python package that installed the python backend. This seemed to work, and things were matching. The python executable and modules available were matching what I access in a terminal --- This is what my expected behavior is!

On a computer with Rocky Linux 8 (a RHEL clone), it's quite a bit more confusing. From their repos, I've installed cantor (19.12.2) and the package "python3-cantor" that installs the python backend. On this system, I use anaconda as my python binary. There is a strange discrepancy though between the output from within cantor and the output from invoking python with a shell.

Example python code:
Code: Select all
import sys
print(sys.version)
print(sys.executable)


Cantor output:
Code: Select all
3.6.8 (default, Feb 21 2023, 16:57:46) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-16)]
/usr/remote/apps/anaconda/2022.05/bin/python3


Shell output:
Code: Select all
~ $ which python
/usr/remote/apps/anaconda/2022.05/bin/python
~ $ python -c "import sys; print(sys.version); print(sys.executable)"
3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:56:21)
[GCC 10.3.0]
/usr/remote/apps/anaconda/2022.05/bin/python


(The executables listed above are all symlinked to a python3.9 binary in the same directory)


I'm confused as to why the executables are listed as the same, but the versions are entirely different. The `sys.path` list is also different, which I suspect is why I cannot import various modules from within cantor. Cantor seems to be running a python 3.6 executable and library/modules.

I guess my question is how does cantor select its python executable? Is this an environment variable I can set, or a setting I can choose? I don't really see any options in the GUI settings of Cantor itself.

I'm also curious if I can use the snap or flatpak version, but point the python binary and libraries to the system libraries I use.


And with a bit more searching I do have a python3.6 file located at `/usr/bin/python3.6` which ultimately points to `/usr/libexec/platform-python3.6`. I'm guessing that somehow cantor ends up running this, but would like to be able to specify my preferred python.

Thanks, any help is appreciated! I very well may just be confused about something or missing a step in the configuration, but I couldn't find much in the documentation.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]