Recent

Author Topic: python for lazarus  (Read 3753 times)

suibaf

  • New Member
  • *
  • Posts: 16
python for lazarus
« on: July 05, 2022, 09:53:04 pm »
Hi,
I'm trying to permit to work to a app that I found on youtube that is an example of python for lazarus:

https://www.youtube.com/watch?v=WREEoECCMy0

In general it work, with simply python command, but if I try to run a python example of matplotlib with lazarus app it give me an error.

If I run the same python code with Idle or Thonny it work fine. The lazarus give me this error:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "/usr/bin/python3"
  * The NumPy version is: "1.23.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /home/fabio/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyObject_SelfIter
.

Press OK to ignore and risk data corruption.
Press Abort to kill the program
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Can you help me to understand what is the problem?
I run with lazarus 2.2.2 on Linux Mint.
BR




mercurhyo

  • Full Member
  • ***
  • Posts: 235
Re: python for lazarus
« Reply #1 on: July 06, 2022, 02:37:24 am »
so the error said itself ... "IMPORTANT... SEE NUMPY" I guess you should ask NUMPY if any forum
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1218
Re: python for lazarus
« Reply #2 on: July 06, 2022, 03:48:32 am »
hello,
how have you installed the module matplotlib ? with pip ? with apt-get install ?
I have no problem on Ubuntu 20.04 Lazarus 2.2  Last version of Python4Lazarus python 3.8 to import matplotlib in a python script used by Python4Lazarus.
matplotlib installed with the command :
Quote
apt-get install python3-matplotlib
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

suibaf

  • New Member
  • *
  • Posts: 16
Re: python for lazarus
« Reply #3 on: July 06, 2022, 01:45:28 pm »
I'm going to try to reinstall matplotlib, but if I run the python code with thonny or with Pycharm it work fine!

No work inside the lazarus app.

Thank you

suibaf

  • New Member
  • *
  • Posts: 16
Re: python for lazarus
« Reply #4 on: July 06, 2022, 09:05:59 pm »
As yuo can see with thonny the code python work, inside the lazarus app no!
Thank you

AlexTP

  • Hero Member
  • *****
  • Posts: 2233
    • UVviewsoft
Re: python for lazarus
« Reply #5 on: July 06, 2022, 10:10:23 pm »
I am not sure Python4Lazarus lacks something, yes it lacks 'PyObject_SelfIter' symbol, but Python4Delphi (original project) lacks it too!

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1218
Re: python for lazarus
« Reply #6 on: July 07, 2022, 07:15:22 am »
Hello,
As yuo can see with thonny the code python work, inside the lazarus app no!
No problem to run your python script in Lazarus on Ubuntu 20.04 (see attachment).
the packages numpy and matplotlib are in the folder /usr/lib/python3/dist-packages
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

suibaf

  • New Member
  • *
  • Posts: 16
Re: python for lazarus
« Reply #7 on: July 07, 2022, 10:41:41 am »
I'm newbie of Lazarus, so I don't know what can I do.
Can you send me your code?
BR

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1218
Re: python for lazarus
« Reply #8 on: July 07, 2022, 11:48:42 am »
in attachments, lazarus project using Python4Lazarus and matplotlib
MAy be you need to change the properties  DllName, DllPath and regVersion of the TPythonEngine component (see attachment for an example).
Friendly, J.P
« Last Edit: July 07, 2022, 11:56:09 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

suibaf

  • New Member
  • *
  • Posts: 16
Re: python for lazarus
« Reply #9 on: July 07, 2022, 08:59:48 pm »
Your app work perfectly!

suibaf

  • New Member
  • *
  • Posts: 16
Re: python for lazarus
« Reply #10 on: July 08, 2022, 04:51:12 pm »
As I said your app work very well, but if I calcel pythonengine from the form and then I put on the form new pythonengine it does not work, also if I write correct reference to dllname and dllpath. There is something in my system that is corrupt.

BR

Mongkey

  • Sr. Member
  • ****
  • Posts: 378
Re: python for lazarus
« Reply #11 on: June 07, 2023, 05:40:38 am »
I was trying on windows 7,
python_console -> it failed -> open & suddenly closed, all dll, DLLs, pythonxx.zip already there,
python_thread -> it failed -> seems zip file not extracted just like on arduino IDE esp framework fault,

how to solve this?

Thank you!
« Last Edit: June 07, 2023, 05:50:41 am by Mongkey »

Mongkey

  • Sr. Member
  • ****
  • Posts: 378
Re: python for lazarus
« Reply #12 on: June 09, 2023, 06:23:44 am »
I did it on ubuntu, but i got another problem, if i try to import cv2 it always say cv2 has no member __version__?

I checked it has installed cv2 version 3.2.0

Thank you

python script to exec:
Code: Python  [Select][+][-]
  1. import cv2
  2. print(cv2.__version__)
  3.  
« Last Edit: June 09, 2023, 06:31:38 am by Mongkey »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1218
Re: python for lazarus
« Reply #13 on: June 10, 2023, 09:36:33 am »
Hello,
What is your version of Ubuntu ? and the version of Lazarus ? it seems you have an old version of opencv. Have you installed the package python3-opencv ? On Ubuntu 20.04 with Lazarus 2.2.4 i have no problem to import cv2 and print the version (see attachment). And if you want only use python to use opencv don't forget the lazarus package : Opencv version 4.6 C++ API wrapper

Code: Pascal  [Select][+][-]
  1. implementation
  2. uses  OPENCVWrapper;
  3. {$R *.lfm}
  4.  
  5.  
  6. procedure TForm6.btnStartClick(Sender: TObject);
  7. var
  8.     version: AnsiString;
  9.  
  10. begin
  11.   version := pCvgetVersionString().pstr;
  12.   ShowMessage('OpenCv Version : ' + version);
  13. end;    
  14.  

Friendly, J.P
« Last Edit: June 10, 2023, 01:08:08 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Mongkey

  • Sr. Member
  • ****
  • Posts: 378
Re: python for lazarus
« Reply #14 on: June 11, 2023, 01:38:50 am »
Thank you for your fast respone JP,

my ubuntu is 18.04
lazarus 2.2.4

Update:
I already did, all readme.txt of opencvwrapper, seems this wrapper is not for me, i would like to use python as http server and opencv image processor, it quite easy than combining pascal + python. Thank you.
« Last Edit: June 11, 2023, 03:41:43 am by Mongkey »

 

TinyPortal © 2005-2018