LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Thonny not starting (https://www.linuxquestions.org/questions/slackware-14/thonny-not-starting-4175714063/)

FlinchX 07-01-2022 01:23 PM

Quote:

Originally Posted by SAJM
I just installed Thonny using sbopkg on my laptop and it will not load.

Quote:

Originally Posted by SAJM
I'm running 14.2 and a KDE Desktop.

How exactly did you install it? Please describe the exact sequence of actions that you performed. Did you just start sbopkg, searched for "thonny", then installed it? If so, it's very likely that it's the wrong way to do it, in either 14.2 or 15.0. If you go to the corresponding page on SBo http://slackbuilds.org/repository/14.2/python/thonny/ you will see that it has build dependencies. Hence, you need to generate the queue file for it:

Code:

# sqg -p thonny
Then start sbopkg, load the queue for thonny and install all the packages, as in both thonny and its dependencies.

Quote:

Originally Posted by SAJM
Here is what I got

Code:


bash-4.3$ python
Python 2.7.17 (default, Oct 20 2019, 14:16:51)
[GCC 5.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> #or
... python3
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'python3' is not defined
>>>
KeyboardInterrupt
>>>


:( This proves that you just blindly copypasted the whole without thinking. You were supposed to do

Code:


bash-4.3$ python3

after you did

Code:


bash-4.3$ python

First would check the default python version, second would explicitly check if you have python3

Quote:

Originally Posted by SAJM
I installed Python3

Again, no details about how exactly did you install Python3. And this probably implies that you did not have it already installed for something else before thonny. Then that probably you didn't go through the queue file workflow mentioned above, otherwise python3 would've been installed when you ran the queue for thonny in sbopkg.

Quote:

Originally Posted by pan64
I don't really know how did you try to start thonny, but probably
Code:

pip3 install thonny
thonny

or something similar will work.

IMHO suggesting to install software provided by SBo via pip to somebody who's not very experienced (see my copypaste comment above) will only add more confusion. Your example command will work as root, mixing stuff installed for python3 via sbopkg from SBo and software for the same python3 installed directly via pip, which is a VERY bad thing. It's possible to install things via pip as regular user, but then the pip command requires an additional --user command line argument. Yet I'm not sure using pip is needed, as I said above.

Quote:

Originally Posted by pan64
But probably you need to install tkinter (python3-tk) too.

Oh please, this is Slackware, not Debian. It doesn't split python into multiple packages, adding even more confusion. If python3 was installed correctly, via the SBo script for 14.2, it contains tk, just like the vanilla python2 package. Lack of tk in python3 means that probably python3 was installed differently, hence I asked OP above to provide more details.

Quote:

Originally Posted by BrunoLafleur
Maybe python3 was compiled without TK support.

So it seems it could be installed with :

> pip3 install tk

Please, stop suggesting pip in this context. Slackware 14.2 was the stable version for many years. You don't imagine SBo shipped python3 with no tk, considering that vanilla python2 in Slackware doesn't split the python package? See above.

SAJM 07-01-2022 02:17 PM

How do I configure python for Tk?

As per the final error in #12 above.

I'm guessing that the standard Python install does not use Tk. Tk is something unique to Thonny

SAJM 07-01-2022 03:00 PM

Quote:

Originally Posted by FlinchX (Post 6364942)
Did you just start sbopkg, searched for "thonny", then installed it?

That's exactly what I did. It seemed logical and has worked in the past.
I always understood the dependencies were all installed as a package when using sbopkg

teckk 07-01-2022 03:10 PM

Open a python3 shell, and see if you can import tkinter. If not what is the error.

Or just keep ignoring the advise you are given.

Edit:
https://docs.python.org/3/index.html
https://docs.python.org/3/library/tkinter.html

SAJM 07-01-2022 03:12 PM

I removed Python3 and reinstalled it paying particular attention to the output. It was very fast but I did see mention of tk flash past but it still was not installed

teckk 07-01-2022 03:20 PM

You are new to python. You are going to have an impossible time, unless you start at step one, then 2...

Arch calls python3 python, Slack might call that python3. It's your box, find out.

Code:

python
Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import tkinter
>>> help(tkinter)
...

Help on package tkinter:

NAME
    tkinter - Wrapper functions for Tcl/Tk.

MODULE REFERENCE
    https://docs.python.org/3.10/library/tkinter.html
   
    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

DESCRIPTION
    Tkinter provides classes which allow the display, positioning and
    control of widgets. Toplevel widgets are Tk and Toplevel. Other
    widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,
    Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox
    LabelFrame and PanedWindow.
   
    Properties of the widgets are specified with keyword arguments.
    Keyword arguments have the same name as the corresponding resource


SAJM 07-01-2022 03:30 PM

Quote:

Originally Posted by teckk (Post 6364965)
Open a python3 shell, and see if you can import tkinter. If not what is the error.

Or just keep ignoring the advise you are given.

Edit:
https://docs.python.org/3/index.html
https://docs.python.org/3/library/tkinter.html

I think you will find I have already posted output from the python3 shell.

FlinchX 07-01-2022 03:31 PM

Quote:

Originally Posted by SAJM (Post 6364964)
That's exactly what I did. It seemed logical and has worked in the past.

I suppose by "in the past" you rather mean "for other software". This indeed works. For software with no build dependencies. For software with build dependencies, you need to install them explicitly yourself, even if you use sbopkg. Or make use of queues, as I explained above.

Quote:

Originally Posted by SAJM (Post 6364964)
I always understood the dependencies were all installed as a package when using sbopkg

No, not with sbopkg.

teckk 07-01-2022 03:38 PM

Quote:

I think you will find I have already posted output from the python3 shell.
Not once have you posted the output of a python3 shell. You posted the output to a python2 shell. They are different.

@FlinchX says Slack calls python3.python3

Are you going to post that or not?
Code:

python3
Then you can see if you can import tkinter in that shell. I am going to guess that you don't have tk/tcl installed. tkinter wont work without it.

Or, you could check and see if you have that installed.

teckk 07-01-2022 03:43 PM

After you get/have python3 working, tk/tcl installed so that tkinter will work...

Here is a simple little test script to see if all is well, with tkinter.

test.py
Code:

#!/usr/bin/python

from tkinter import *
from tkinter import font
from tkinter import ttk
 
class A(Tk):
    def __init__(self,*args,**kwargs):
        Tk.__init__(self,*args,**kwargs)
        self.notebook = ttk.Notebook()
        self.geometry('600x600')
        self.add_tab()
        self.notebook.grid(row=0)
 
    def add_tab(self):
        tab1 = B(self.notebook)
        tab2 = C(self.notebook)
        tab3 = D(self.notebook)
        self.notebook.add(tab1,text="Tab1")
        self.notebook.add(tab2,text="Tab2")
        self.notebook.add(tab3,text="Tab3")

class B(Frame):
    def __init__(self,name,*args,**kwargs):
        Frame.__init__(self,*args,**kwargs)
        self.label = Label(self, text="Info for Tab1")
        self.label.config(font=24, bg='blue', fg='yellow')
        self.label.grid(row=1,column=0,padx=50,pady=100)
        self.name = name
 
class C(Frame):
    def __init__(self,name,*args,**kwargs):
        Frame.__init__(self,*args,**kwargs)
        self.label = Label(self, text="Info for Tab2")
        self.label.config(font=24, bg='green', fg='white')
        self.label.grid(row=1,column=0,padx=100,pady=150)
        self.name = name
     
class D(Frame):
    def __init__(self,name,*args,**kwargs):
        Frame.__init__(self,*args,**kwargs)
        self.label = Label(self, text="Info for Tab3")
        self.label.config(font=24, bg='yellow', fg='black')
        self.label.grid(row=1,column=0,padx=150,pady=200)
        self.name = name
 
my_app = A()
my_app.mainloop()

You can make that executable run it, or
Code:

python3 ./test.py

FlinchX 07-01-2022 03:44 PM

Quote:

Originally Posted by SAJM (Post 6364966)
I removed Python3 and reinstalled it

Again, how exactly did you install it? Via sbopkg as well? Is it this Python 3? http://slackbuilds.org/repository/14.2/python/python3/

SAJM 07-02-2022 05:42 AM

Quote:

Originally Posted by FlinchX (Post 6364974)
Again, how exactly did you install it? Via sbopkg as well? Is it this Python 3? http://slackbuilds.org/repository/14.2/python/python3/

Yes. With sbopkg

FlinchX 07-02-2022 06:12 AM

@SAJM Did you have a full 14.2 install before you started to install SBo things?

SAJM 07-02-2022 06:16 AM

Quote:

Originally Posted by teckk (Post 6364973)
After you get/have python3 working, tk/tcl installed so that tkinter will work...

Here is a simple little test script to see if all is well, with tkinter.

test.py
[

Code:

python3 ./test.py

Result:

[CODE}
bash-4.3$ python3 ./test.py
Traceback (most recent call last):
File "./test.py", line 3, in <module>
from tkinter import *
File "/usr/lib64/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
bash-4.3$
[/CODE]

EDIT

oops I just noticed I should have run this after the Tk issue was resolved!!

SAJM 07-02-2022 06:20 AM

Im going to remove everything and start again in this order

1. Install Python3
2. Install Thonny

Paying particular attention to dependencies.


All times are GMT -5. The time now is 03:53 AM.