WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: my adventures with installing python3.9 on TC15  (Read 252 times)

Offline Stefann

  • Jr. Member
  • **
  • Posts: 82
my adventures with installing python3.9 on TC15
« on: March 23, 2025, 09:35:11 AM »
Hi,
This weekend I succeeded in getting python3.9 on TC15 TinyCore.
I would like to share my experiences because it was not a completely smooth ride.
I will skip all detours I made and just get to how I finally succeeded.
Note that I run my system frugal: with tc home directory in ram.

Code: [Select]
got python3.9 on by getting python3.9-setuptools.tcz downloaded and "on demand"
check:
tc@hp510:~$ python3 --version
Python 3.6.15

tc@hp510:~$ python3.9 --version
Python 3.9.18
note: not sure I would need the setup tools. I installed them just to be sure.

strangly enough the 3.9 not only installs 3.9 but also some 3.6 residuals:
Code: [Select]
tc@hp510:/usr/local/bin$ ls -al python3*
lrwxrwxrwx    1 root     root             9 Mar 22 12:47 python3 -> python3.6
lrwxrwxrwx    1 root     root            16 Mar 22 12:47 python3-config -> python3.6-config
-rwxr-xr-x    2 root     root         13760 Dec  7  2023 python3.6
lrwxrwxrwx    1 root     root            17 Mar 22 12:47 python3.6-config -> python3.6m-config
-rwxr-xr-x    2 root     root         13760 Dec  7  2023 python3.6m
-rwxr-xr-x    1 root     root          3061 Dec  7  2023 python3.6m-config
-rwxr-xr-x    1 root     root         13728 Jan 27  2024 python3.9
-rwxr-xr-x    1 root     root          3034 Jan 27  2024 python3.9-config

after that I did need some modules that are not offered as tcz.
I tried "pip" but that did not work
I succeeded getting pip by:
Code: [Select]
python3.9 -m ensurepip --default-pip
python3.9 -m pip install --upgrade pip

This did NOT install pip in /usr/local but in my tc home directory:
tc@hp510:~/.local/lib/python3.9/site-packages

After that I successfully installed some modules:
Code: [Select]
python3.9 -m pip install python_dateutil==2.8.2
python3.9 -m pip install beautifulsoup4==4.11.1
python3.9 -m pip install pytz==2022.2.1
python3.9 -m pip install requests==2.28.1
python3.9 -m pip install paho_mqtt==1.6.1

all got installed in:
~/.local/lib/python3.9/site-packages

As I run with home in RAM (so, not persistent) this would unnecessarily increase the backup for home
I solved that by following "Chapter 14. Creating a personal (data) extension" from the core book to create a data extension for the content of ~/.local/lib/python3.9/site-packages and adding home/tc/.local/lib/python3.9/site-packages to .xfiletool.lst.

So...
This all works...
But it's not super clean

What I would hope (actually not for me as I'm fine now, but probably for others)
- cleanup the python3.9 tcz package such that no 3.6 stuff is created
- update pip in python3.9 tcp package such that it works out of the box, and not installs on ~/.local

Next to that..
- creating a data extension for ~/.local/lib/python3.9/site-packages is a bit ugly.
- it would be better to create tcz program extensions for the modules

I'm afraid all of these are at this moment beyond my capabilities.

Actually... I feel that "if I would have installed the modules under root", they would have landed in /usr/local/lib/python3.9/site-packages from which either a data-extension or program extension would have been a much cleaner approach.
However.... running pip under root gives a fat warning that it may corrupt python. So... I did not dare to do.

All in all:
I'm totally happy now.
Fixing all of the above is really beyond my capabilities so I'm afraid I cannot assist to fix.
So with that said: Either consider this an instruction guide towards pyhton3.9 install OR a suggestion for fix.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15044
Re: my adventures with installing python3.9 on TC15
« Reply #1 on: March 23, 2025, 01:52:49 PM »
The tree file for python3.9-setuptools in the tc-15.x x86 repo does not contain any references to python3.6.

This means that some other extension you are loading is pulling in python3.6.

Offline Stefann

  • Jr. Member
  • **
  • Posts: 82
Re: my adventures with installing python3.9 on TC15
« Reply #2 on: March 23, 2025, 03:39:39 PM »
Mhh strange…
I thought I checked that.
But as I said… it was a full Saturday of hobbying until I had it working.
I tried to make it a “clean story” but I may have done something wrong.

I will check again tomorrow and report back.

Offline Stefann

  • Jr. Member
  • **
  • Posts: 82
Re: my adventures with installing python3.9 on TC15
« Reply #3 on: March 24, 2025, 11:02:06 AM »
OK, you are right.
Don't understand it because I thought I had checked this !!!!!!
But anyways..

Code: [Select]
run visual apps browser
click "dependancies"
click "python3.6.tcz"
click "required by"
- libxml2-dev.tcz.      >> required by php-8.3-dev.tcz
- libxml2-python.tcz. >> required by php-8.3-dev.tcz
- php-8.3-dev.tcz.     >> yes I have installed that
- python3.6-pip.tcz
- python3.6-setuptools.tcz

so, yes I have php-8.3-dev.tcz installed.
I use php, but not sure I also need the -dev module. I merely loaded it "just to be sure".

Next step
Code: [Select]
removed php-8.3-dev.tcz from on demand list.
reboot with backup

tc@hp510:/usr/local/bin$ ls py* -al
lrwxrwxrwx    1 root     root             8 Mar 24 17:55 pydoc3 -> pydoc3.9
-rwxr-xr-x    1 root     root            84 Jan 27  2024 pydoc3.9
lrwxrwxrwx    1 root     root             9 Mar 24 17:55 python3 -> python3.9
lrwxrwxrwx    1 root     root            16 Mar 24 17:55 python3-config -> python3.9-config
-rwxr-xr-x    1 root     root         13728 Jan 27  2024 python3.9
-rwxr-xr-x    1 root     root          3034 Jan 27  2024 python3.9-config
so.. yesss... python3.6 disappeared!

I only use php inside apache webserver.
I checked my application
webpage still seems to function.
So... keep it off for now.

That's solves 1 thing!
Happy with it. don't like to have 2 versions of python on my system, so thanks Juanito


now... python3.9 apparently is also installed even though I did not install it.
Code: [Select]
Checked "required by"
- indeed many "required by's"
- especially "libusb-compat-dev.tcz" >>> yes... and I sure need that one

So now it remains a bit unclear why I did need to upgrade pip >> I'm not going to look into that, I'm happy it works
And a bit ugly to have pip & extra modules under ~/.local >> I will live with that.




« Last Edit: March 24, 2025, 11:09:46 AM by Stefann »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15044
Re: my adventures with installing python3.9 on TC15
« Reply #4 on: March 25, 2025, 02:11:37 AM »
There are 15+ python3.9 extensions in the tc-15.x x86 repo.

If you don't see the one you need, it's not difficult to make a python extension.

Taking as an example python certifi:
Code: [Select]
tce-load -i compiletc python3.9-dev squashfs-tools

wget https://files.pythonhosted.org/packages/71/da/e94e26401b62acd6d91df2b52954aceb7f561743aa5ccc32152886c76c96/certifi-2024.2.2.tar.gz
tar xf certifi-2024.2.2.tar.gz

cd certifi-2024.2.2

python3.9 setup.py build
sudo python3.9 setup.py install --root=/tmp/pkg

Then delete all of the __pycache__ subdirectories under /tmp/pkg/usr/local/lib/python3.9/site-packages

Finally make an extension:
Code: [Select]
cd /tmp
sudo mksquashfs pkg/ python3.9-certifi.tcz
« Last Edit: March 25, 2025, 02:14:20 AM by Juanito »

Offline Stefann

  • Jr. Member
  • **
  • Posts: 82
Re: my adventures with installing python3.9 on TC15
« Reply #5 on: March 25, 2025, 03:04:13 AM »
Thanks,
Yes! There are extensions in TC15 But unfortunately not the ones I needed.

Thanks for the example, seems doable, and I really needed that as a guidance otherwise I would never have gotten there.

For your information:
- I’m not familiar with python at all, the only reason I want python is because someone wrote a python coded interface to read cloud-data from my EV-car and I wanted to use that interface
- which got me on a very steep learning curve towards python.
- installing python via tcz mechanism was relatively straightforward, but extending with non tcz modules was an enormous trial & error excersize
- after lot of trying and googling I got where I currently am as described in 1st post. With some spots.. but working. Happy!
- but… as said… I’d don’t like the spots.

So…
Thanks for the example… really helps…
- so far I used pip for extending. That works relatively smooth. But… you cannot run pip as root as it may messup versions. And as a result of that you get a rather ugly install in ~/.local.
- as by your example, proper way to install in /usr/local is by downloading the .gz and installing by setup.py. Thanks for that guidance… it’s totally new for me. It will definitely cost me trial and error to do that but seems doable (And that’s part of the fun).
- creating the .tcz extends after that I should be able to do. I basically already did the same already by creating a data .tcz extension.

I will give it a try!
This will take some days. There is more on my plate.
But I’ll report back how it went.

Thanks!