Lazarus

Programming => General => Topic started by: suibaf on July 05, 2022, 09:53:04 pm

Title: python for lazarus
Post by: suibaf 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



Title: Re: python for lazarus
Post by: mercurhyo 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
Title: Re: python for lazarus
Post by: Jurassic Pork 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
Title: Re: python for lazarus
Post by: suibaf 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
Title: Re: python for lazarus
Post by: suibaf 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
Title: Re: python for lazarus
Post by: AlexTP 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!
Title: Re: python for lazarus
Post by: Jurassic Pork 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
Title: Re: python for lazarus
Post by: suibaf 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
Title: Re: python for lazarus
Post by: Jurassic Pork 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
Title: Re: python for lazarus
Post by: suibaf on July 07, 2022, 08:59:48 pm
Your app work perfectly!
Title: Re: python for lazarus
Post by: suibaf 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
TinyPortal © 2005-2018