Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: giaco_fab on September 29, 2020, 02:43:17 AM

Title: python
Post by: giaco_fab on September 29, 2020, 02:43:17 AM
Hi

Tkinter doesn't works request libtk8.6.so that seems to be missing
libtk8.5.so is present

Also python for raspberry is updated to 3.8 but the one for "desktop" is still at 3.6 version

Title: Re: python
Post by: Juanito on September 29, 2020, 04:00:53 AM
Which version and which architecture are you speaking of - piCore-11.x?

If so, are you using the python extension from piCore-9.x or the python2.7 extension from piCore-11.x?
Title: Re: python
Post by: giaco_fab on September 29, 2020, 05:43:56 AM
piCore-11.0.zip on raspberry

Core-11.1.iso on virtualbox

I downloaded python with tce-load -w ... I don't know which ones it downloaded  ;D
 
Title: Re: python
Post by: Juanito on September 29, 2020, 08:15:33 AM
piCore-11.x has python extensions named python2.7 and python3.8

Core-11.x has python extensions named python and python3.6

Can you give more details about the error messages you get with tkinter on Core and "desktop" on piCore?
Title: Re: python
Post by: giaco_fab on September 30, 2020, 02:11:08 PM
error attached

Same error on both versions
Title: Re: python
Post by: Juanito on October 01, 2020, 04:06:36 AM
Was the tk8.6 extension loaded (tk in piCore)?
Title: Re: python
Post by: Juanito on October 01, 2020, 04:38:38 AM
This opens a window:
Code: [Select]
$ tce-load -i python tk8.6
$ python
>>> import sys
>>> import Tkinter as tk
>>> root = tk.Tk()
Title: Re: python
Post by: giaco_fab on October 01, 2020, 04:43:56 AM
oh my god  :-[

tk is for python2
tk8.6 for python 3
?

Sorry :-[



Title: Re: python
Post by: Juanito on October 01, 2020, 04:48:56 AM
No, tk8.6 works with both python(2.7) and python3.6 in x86:
Code: [Select]
$ tce-load -i python3.6 tk8.6
$ python3.6
>>> import sys
>>> import tkinter as tk
>>> root = tk.Tk()
Title: Re: python
Post by: giaco_fab on October 01, 2020, 05:15:58 AM
sorry but...
now it works on desktop
tk8.6 seems to not be present for raspberry ??
 http://tinycorelinux.net/11.x/armv6/tcz/
I searched for tk8.6 for armv6 witout founding it at the beginning  ;D
it says no module named _tkinter on rpi
it may be not configured for tk




Title: Re: python
Post by: Juanito on October 01, 2020, 05:31:00 AM
In the piCore-11.x repo the extensions are called python2.7 and tk.
Title: Re: python
Post by: Juanito on October 01, 2020, 05:46:52 AM
I just checked piCore and it looks like you are right:
Code: [Select]
$ tce-load -i python2.7 tk
$ python2.7
>>> import sys
>>> import Tkinter as tk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
Title: Re: python
Post by: giaco_fab on October 01, 2020, 06:29:43 AM
okkk
I started thought i'm stupid  ;D

python3.8 on picore (I need to use 3.x) has same problem

A question if possible:
I tied to compile using :
http://tinycorelinux.net/11.x/x86/tcz/src/python3.6/compile_python3.6
but I get an error on this two lines
edit setup.py
curses_includes.append('/usr/local/include/ncursesw')
what is missing ? How to get it


Title: Re: python
Post by: Juanito on October 01, 2020, 06:36:54 AM
The ncurses headers (ncurses-dev extension) are in /usr/local/include in piCore.
Title: Re: python
Post by: Rabie on July 18, 2021, 03:39:03 PM
hello there,

i have the same problem with piCore 13.x/armv7

i cant find tk8.6 and i am getting "import _tkinter # If this fails your Python may not be configured for Tk"

how do fix that ?
THx
Title: Re: python
Post by: Rich on July 18, 2021, 03:49:53 PM
Hi Rabie
Isn't this it:
http://tinycorelinux.net/13.x/armv7/tcz/tk.tcz.info
Title: Re: python
Post by: Rabie on July 19, 2021, 09:22:55 AM
Hi Rich,
i did install the tk.tcz and the tcl.tcz and i am getting this error anyway

I tried with python2.7, python3.8 and python3.9 is the same
I did try to reinstall python but without success.

On Tinycore V.10 i didn't have this Problem but there was the tk8.6 and tcl8.6.tcz

What can also try ?

Thx

Title: Re: python
Post by: Juanito on July 19, 2021, 11:47:02 AM
Does python have a file with a name similar to /usr/local/lib/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so?
Title: Re: python
Post by: Juanito on July 20, 2021, 11:04:49 AM
As per the *tcz.list files in piCore-13.x armv7, python2.7, python3.8 and python3.9 do not contain _tkinter*.so, so I would guess (I may be wrong) that they were not compiled against tk.
Title: Re: python
Post by: Rich on July 20, 2021, 02:36:22 PM
Hi Rabie
... On Tinycore V.10 i didn't have this Problem but there was the tk8.6 and tcl8.6.tcz ...
That sounds like you are talking about x86:
http://tinycorelinux.net/10.x/x86/tcz/tcl8.6.tcz.info

or x86_64:
http://tinycorelinux.net/10.x/x86_64/tcz/tcl8.6.tcz.info

TC10 for ARM only has version 8.7a1:
http://tinycorelinux.net/10.x/armv7/tcz/tcl.tcz.info
Title: Re: python
Post by: Rabie on July 23, 2021, 06:28:41 AM
Does python have a file with a name similar to /usr/local/lib/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so?
Hi Juanito,

no, this is all i can find with the command:
sudo find / -name "*tkinter*"

/usr /local /lib /python3.9 /tkinter
/tmp /tcloop /python3.9 /usr /local /lib /python3.9/tkinter :(

As per the *tcz.list files in piCore-13.x armv7, python2.7, python3.8 and python3.9 do not contain _tkinter*.so, so I would guess (I may be wrong) that they were not compiled against tk.
Can i compile it somehow ?
Title: Re: python
Post by: Rabie on July 23, 2021, 07:16:47 AM
Quote
That sounds like you are talking about x86:
http://tinycorelinux.net/10.x/x86/tcz/tcl8.6.tcz.info

or x86_64:
http://tinycorelinux.net/10.x/x86_64/tcz/tcl8.6.tcz.info
Hi Rich,
yes i am talking about TinyCore x86_64

But how could i take a tkinter program to work on piCore armv7 V13.x  :-\

Title: Re: python
Post by: Juanito on July 23, 2021, 07:57:46 AM
Drop the python maintainer a pm to request if they could recompile python against tk.
Title: Re: python
Post by: Rabie on July 26, 2021, 08:15:00 AM
Hi Juanito,

i did install python3.6 from Version /8.x/armv7/

but i am missing now this extension "python3.6-cryptography.tcz" and its dependancy

Could you help with that ?

Thx
Title: Re: python
Post by: Juanito on July 26, 2021, 08:33:03 AM
Are you using python3.6 from the piCore-8.x repo (I see it contains _tkinter.cpython-36m-arm-linux-gnueabihf.so and presumably works with tk) in pyCore-13.x?

You can see how python-cryptography was compiled for CorePure64 here:

http://tinycorelinux.net/11.x/x86_64/tcz/src/python-cryptography/compile_python-cryptography
Title: Re: python
Post by: Juanito on July 26, 2021, 09:16:44 AM
As a test in piCore64, pip installed cffi-1.14.6,  pycparser-2.20 and cryptography-3.4.7
Title: Re: python
Post by: Rabie on July 26, 2021, 09:52:48 AM
Are you using python3.6 from the piCore-8.x repo (I see it contains _tkinter.cpython-36m-arm-linux-gnueabihf.so and presumably works with tk) in pyCore-13.x?

You can see how python-cryptography was compiled for CorePure64 here:

http://tinycorelinux.net/11.x/x86_64/tcz/src/python-cryptography/compile_python-cryptography

Hi Juanito,
yes exactly

Quote
You can see how python-cryptography was compiled for CorePure64 here:

I also did downloaded the extension "python3.6-cryptography.tcz" from the Repo. of CorePure64 /10.x/x86_64/
and installed it on my PiCore-13.x but now when i run the Program, who shlould import from Cryptography.
I get this error:

Code: [Select]
Traceback (most recent call last):
  File "/opt/Scripts/.NFZ_RDP.py", line 5, in <module>
    from cryptography.fernet import Fernet
  File "/usr/local/lib/python3.6/site-packages/cryptography/fernet.py", line 17, in <module>
    from cryptography.hazmat.primitives import hashes, padding
  File "/usr/local/lib/python3.6/site-packages/cryptography/hazmat/primitives/padding.py", line 13, in <module>
    from cryptography.hazmat.bindings._padding import lib
ImportError: /usr/local/lib/python3.6/site-packages/cryptography/hazmat/bindings/_padding.abi3.so: wrong ELF class: ELFCLASS64

when i try to use pip to install cryptography i get:

Code: [Select]
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting cryptography
  Could not fetch URL https://pypi.python.org/simple/cryptography/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement cryptography (from versions: )
No matching distribution found for cryptography

any Ideas?
Title: Re: python
Post by: Juanito on July 26, 2021, 10:07:54 AM
You cannot use extensions compiled for one architecture (CorePure64) in another architecture (piCore) - this why you get the error "wrong ELF class: ELFCLASS64".

In addition, if you use an extension from an earlier version (8.x) of the same architecture, you run the risk that one of its dependencies has been updated in the most recent version (13.x) and is no longer compatible.

piCore-8.x uses openssl-1.0.2, which is not compatible with piCore-13.x openssl-1.1.1.
Title: Re: python
Post by: Juanito on July 26, 2021, 10:14:51 AM
If you haven't heard from the python3.8 maintainer, one solution is to compile your own python extension against ncurses, openssl and tk and then compile python-cryptography against that.

You could use this:

http://tinycorelinux.net/11.x/x86_64/tcz/src/python3.6/compile_python3.6

..but substitute "-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" for "-flto -fuse-linker-plugin -mtune=generic -Os -pipe"
Title: Re: python
Post by: Rabie on July 27, 2021, 12:54:11 PM
You cannot use extensions compiled for one architecture (CorePure64) in another architecture (piCore) - this why you get the error "wrong ELF class: ELFCLASS64".

In addition, if you use an extension from an earlier version (8.x) of the same architecture, you run the risk that one of its dependencies has been updated in the most recent version (13.x) and is no longer compatible.

piCore-8.x uses openssl-1.0.2, which is not compatible with piCore-13.x openssl-1.1.1.
Hi Juanito,
you are absolutely right!


Quote
If you haven't heard from the python3.8 maintainer, one solution is to compile your own python extension against ncurses, openssl and tk and then compile python-cryptography against that.

You could use this:

http://tinycorelinux.net/11.x/x86_64/tcz/src/python3.6/compile_python3.6

..but substitute "-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" for "-flto -fuse-linker-plugin -mtune=generic -Os -pipe"

i am gonna need some help doing that, like how to do it step by step (Cause i am not that pro.)   :-\

i understood that i need to install those extensions
Quote
tce-load -i compiletc openssl-1.1.1-dev sqlite3-dev tk8.6-dev glib2-dev gdbm-dev bzip2-dev Xorg-7.7-dev liblzma-dev readline-dev

Quote
cd Python-3.6.9
edit setup.py

and then go to the directory of Python and edit setup.py

anyway i cant find the file setup.py

Thx
Title: Re: python
Post by: Juanito on July 28, 2021, 10:15:20 AM
You need to uncompressed the source - i.e. “tar xf Python*tar*”
Title: Re: python
Post by: Rabie on July 28, 2021, 10:40:35 AM
Hi Juanito,

and what do i do with this:

Code: [Select]
curses_includes.append('/usr/local/include/ncursesw')

CPPFLAGS="-I/usr/local/include/ncursesw" CC="gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe" CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions -fno-rtti"
Title: Re: python
Post by: Juanito on August 01, 2021, 11:01:16 AM
Edit that line in setup.py

..and then:
Code: [Select]
$ CPPFLAGS="-I/usr/local/include/ncursesw" CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes --with-tcltk-includes='-I/usr/local/include' --with-tcltk-libs='-L/usr/local/lib -ltk8.6 -ltcl8.6
Title: Re: python
Post by: Rabie on August 02, 2021, 11:48:52 AM
Hi Juanito,

when i run this:
Code: [Select]
CPPFLAGS="-I/usr/local/include/ncursesw" CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -
pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes --with-tcltk-includes='-I/usr/local/include' --with-tcltk-libs='-L/usr/local/lib -ltk8.6 -ltcl8.6

this what i get one error about tkinter:

Code: [Select]
In file included from /usr/local/include/tk.h:96,
                 from /opt/Python-3.6.9/Modules/_tkinter.c:50:
/usr/local/include/X11/Xlib.h:44:10: fatal error: X11/X.h: No such file or directory
   44 | #include <X11/X.h>
      |          ^~~~~~~~~



Quote
If you haven't heard from the python3.8 maintainer, one solution is to compile your own python extension against ncurses, openssl and tk and then compile python-cryptography against that.
how do i compile python against ncurses, openssl, tk and python-cryptography ?
Title: Re: python
Post by: Juanito on August 02, 2021, 12:20:54 PM
Did you load the *-dev extensions referenced in the earlier example - i.e. Xorg-dev, tk-dev, openssl-dev, ncurses-dev, etc?
Title: Re: python
Post by: Rabie on August 02, 2021, 12:59:19 PM
Did you load the *-dev extensions referenced in the earlier example - i.e. Xorg-dev, tk-dev, openssl-dev, ncurses-dev, etc?

ops! it seems like i forgot those two liblzma-dev readline-dev

now i have it installed, but i still don't know how to compile it against tk and python-cryptography  :-\

is there another way to save the compiled python after rebooting without puting it in /opt/.filetool.lst ? because it will take so long every time i save something

thx
Title: Re: python
Post by: Juanito on August 02, 2021, 01:13:29 PM
The previous error you got about tk looking for Xlib.h means that (after you loaded Xorg-dev) python did compile against tk.

You can make an extension out of the files loaded by “sudo make install” to avoid recompiling each time you reboot.
Title: Re: python
Post by: Rabie on August 02, 2021, 01:54:59 PM
Quote
The previous error you got about tk looking for Xlib.h means that (after you loaded Xorg-dev) python did compile against tk.

there is no xorg-dev.tcz in the repo. of piCore v13.x armv7 but xorg-server-dev!

Quote
You can make an extension out of the files loaded by “sudo make install” to avoid recompiling each time you reboot.
i already did that but python is not there anymore after reboot, i think there is an missing step :(
Title: Re: python
Post by: Juanito on August 02, 2021, 02:19:27 PM
Sorry, mesa-dev should work in place of xorg-dev.

Does the extension you made contain a symlink from python to python3.6?
Title: Re: python
Post by: Rabie on August 02, 2021, 03:47:04 PM
Quote
you can make an extension out of the files loaded by “sudo make install” to avoid recompiling each time you reboot.

i think we misunderstood each other i already did this step "sudo make install"
but i don't know how to make an extension out of the files that were loaded by the command: "sudo make install"
Title: Re: python
Post by: Juanito on August 03, 2021, 04:05:09 AM
See attached file
Title: Re: python
Post by: Rabie on August 03, 2021, 05:20:46 AM
Hi Juanito,

first sorry for being so noob and for asking to much but i have some questions:

Quote
Code: [Select]
touch mymarker
What is mymaker ?

Quote
Code: [Select]
$ sudo tar -T files --numeric-owner -zcvf extension.tar.gz
where do i find all the files were make by "sudo make install" ? or shlouldn't i replace the word files with a path from those files

Title: Re: python
Post by: Juanito on August 03, 2021, 06:15:42 AM
"touch" writes a zero byte file - in this case named "mymarker".

The complicated command after that makes a list of all files created after "mymarker" and puts the list into a file named "files".

"sudo tar blah-blah" makes a tarball named "extension.tar.gz out of all the files listed in "files".
Title: Re: python
Post by: Juanito on August 03, 2021, 06:24:11 AM
I compiled python3.6 in piCore-12.x - it should work in piCore-13.x, so added to the repo.

Now all you need to do is compile python-cryptography and its deps against python3.6...
Title: Re: python
Post by: Rabie on August 03, 2021, 07:14:50 AM
Hi Juanito,

I compiled python3.6 in piCore-12.x - it should work in piCore-13.x, so added to the repo.
Thank you very much!

Quote
Now all you need to do is compile python-cryptography and its deps against python3.6...
that ist my goal after all, would you tell me how to do that ?

i tried to install it directly with
Code: [Select]
pip3.6 install cryptographyBut i am getting an error  :-[

Title: Re: python
Post by: Juanito on August 03, 2021, 08:12:44 AM
You need something like this:

* "tce-load -i compiletc python3.6-dev"
* "wget [source tarball]"
* "tar xf [source tarball]"
* "cd [source]"
* "python3.6 setup.py build"
* "mkdir /tmp/pkg"
* "sudo python3.6 setup.py install --root=/tmp/pkg"

Then remove the "__pycache__" subdirectories from /tmp/pkg/usr/local/lib/python3.6/site-packages (they are several layers deep)

* "cd /tmp"
* sudo mksquashfs pkg/ python3.6-[source].tcz
Title: Re: python
Post by: Juanito on August 03, 2021, 08:14:19 AM
But i am getting an error

That comment is only useful for telepaths  :P
Title: Re: python
Post by: Rabie on August 04, 2021, 06:56:44 AM
Hi Juanito,

* "python3.6 setup.py build"

Code: [Select]
        =============================DEBUG ASSISTANCE==========================
        If you are seeing an error here please try the following to
        successfully install cryptography:

        Upgrade to the latest pip and try again. This will fix errors for most
        users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
        =============================DEBUG ASSISTANCE==========================

Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    from setuptools_rust import RustExtension
ModuleNotFoundError: No module named 'setuptools_rust'

i installed rust.tcz but it didn't help
any Ideas ?
Title: Re: python
Post by: Juanito on August 04, 2021, 07:54:25 AM
It looks like you need: https://pypi.org/project/setuptools-rust/
Title: Re: python
Post by: Juanito on August 04, 2021, 08:03:21 AM
I'd suggest that you try an earlier version of cryptography that doesn't use rust, for example:

https://github.com/pyca/cryptography/archive/refs/tags/3.2.1.tar.gz
Title: Re: python
Post by: Rabie on August 04, 2021, 09:27:36 AM
Hi Juanito,

thank you very very much my program works finaly  :) :)