python for lazarus lazarus / 21-General ---------------------------------------------------------------------- suibaf · 2022-07-05 19:53 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 · 2022-07-06 00:37 so the error said itself ... "IMPORTANT... SEE NUMPY" I guess you should ask NUMPY if any forum ---------------------------------------------------------------------- Jurassic Pork · 2022-07-06 01:48 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 : Quoteapt-get install python3-matplotlibFriendly, J.P ---------------------------------------------------------------------- suibaf · 2022-07-06 11:45 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 · 2022-07-06 19:05 As yuo can see with thonny the code python work, inside the lazarus app no! Thank you ---------------------------------------------------------------------- AlexTP · 2022-07-06 20:10 I am not sure Python4Lazarus lacks something, yes it lacks 'PyObject_SelfIter' symbol, but Python4Delphi (original project) lacks it too! ---------------------------------------------------------------------- Jurassic Pork · 2022-07-07 05:15 Hello, Quote from: suibaf on July 06, 2022, 09:05:59 pmAs 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 ---------------------------------------------------------------------- suibaf · 2022-07-07 08:41 I'm newbie of Lazarus, so I don't know what can I do. Can you send me your code? BR ---------------------------------------------------------------------- Jurassic Pork · 2022-07-07 09:48 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 ---------------------------------------------------------------------- suibaf · 2022-07-07 18:59 Your app work perfectly! ---------------------------------------------------------------------- suibaf · 2022-07-08 14:51 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 · 2023-06-07 03:40 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! ---------------------------------------------------------------------- Mongkey · 2023-06-09 04:23 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i import cv2print(cv2.__version__) ---------------------------------------------------------------------- Jurassic Pork · 2023-06-10 07:36 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i implementationuses  OPENCVWrapper;{$R *.lfm}  procedure TForm6.btnStartClick(Sender: TObject);var    version: AnsiString; begin  version := pCvgetVersionString().pstr;  ShowMessage('OpenCv Version : ' + version);end;     Friendly, J.P ---------------------------------------------------------------------- Mongkey · 2023-06-10 23:38 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.