-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
You don't need to create and destroy zPythonDelphiVar in every thread. Add zPythonDelphiVar to the form: object zPythonDelphiVar: TPythonDelphiVar Engine = PythonEngine1 Module = '__main__' VarName = 'result' Left = 64 Top = 120 end Then modify ExecuteWithPython to procedure TPythonThread_Test1.ExecuteWithPython; var i: Integer; begin fOutputs := TStringList.Create; for i := 1 to 10000 do begin GetPythonEngine.ExecString(UTF8Encode(Script)); GetPythonEngine.CheckError; fOutputs.Add(Form1.zPythonDelphiVar.Value); end; end; and it should work as you would expect. And since you mentioned it, a fellow Brazilian @lmbelo Lucas Belo, is a major contributor to P4D and would certainly be in a position to help. -
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
You never explained what is the problem. -
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
@djxandytche "Here is my code, please check and find the bugs" is not a good way to get support. Why should anyone spend one hour of their time, understanding and debugging your code? You say you are beginner in Python. Then why do you start by running python code in threads, which requires some expert knowledge? Do you realize that there is no performance benefits in running python code in threads like this? They will be executed sequentially, thanks to the GIL. -
How do I exchange data between python/Lazarus for a 3channel 2d floating-point array
pyscripter replied to RegiStax's topic in Python4Delphi
For Delphi is here: Fundamental Syntactic Elements (Delphi) - RAD Studio (embarcadero.com) and for fpc Identifier - Free Pascal wiki. -
How do I exchange data between python/Lazarus for a 3channel 2d floating-point array
pyscripter replied to RegiStax's topic in Python4Delphi
arr := np.&ones(VarPythonCreate([N, N]), np.float64) You do not need the &. It is only needed when using a keyword such as "array" (and Delphi does not need it even then). -
How do I exchange data between python/Lazarus for a 3channel 2d floating-point array
pyscripter replied to RegiStax's topic in Python4Delphi
Also, since you are interested in image manipulations, have a look at this thread: Place image in a TImage - Python4Delphi - Delphi-PRAXiS [en] (delphipraxis.net) -
How do I exchange data between python/Lazarus for a 3channel 2d floating-point array
pyscripter replied to RegiStax's topic in Python4Delphi
np.float64 corresponds to pascal double. Use double instead of single. Use BuiltinModule.float instead of BuiltinModule.int. For multidimensional arrays you need to use the ndim and shapes fields of the Buffer structure. An array of Py_ssize_t of length ndim indicating the shape of the memory as an n-dimensional array. Note that shape[0] * ... * shape[ndim-1] * itemsize MUST be equal to len. If you know the dimensions of the array you can directly cast to an equivalent pascal multidimensional array. -
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
Have you read the docs and the limitations of using subinterpreters? Initialization, Finalization, and Threads — Python 3.12.4 documentation Also the docs for the PyInterpreterConfig structure? pandas and numpy probably do not support running in subinterpreters. I suggest that you forget about sub-interpreters unless you know very well what you are doing. But then you are on your own. -
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
With SafePyEngine you do not get that choice. It is equivalent to emNewState, which is by far the most common use case. -
Python freezes when running a certain script
pyscripter replied to djxandytche's topic in Python4Delphi
@djxandytche Your code for running python code in threads is reinventing the wheel and the result is evidently incorrect. Just follow the guidelines at PythonThreads · pyscripter/python4delphi Wiki (github.com) paying attention also to the preparation section. Also, have a close look also to Demos 33 and 36. -
A fix has been applied to P4D. Please check.
-
The forthcoming version of PyScripter will have built-in integration with LLM. See the blog post for a taste of the functionality provided.
- 5 replies
-
- pyscripter
- openai
-
(and 1 more)
Tagged with:
-
I am aware of that. This is due Sourceforge changing the way you download files directly. Will work with the next update for this one just download from PyScripter - Manage /PyScripter-v5.0 at SourceForge.net and install.
- 5 replies
-
- pyscripter
- openai
-
(and 1 more)
Tagged with:
-
@Stéphane Wierzbicki PyScripter with LLM support was released. See LLM_Support · pyscripter/pyscripter Wiki (github.com) for details.
- 5 replies
-
- pyscripter
- openai
-
(and 1 more)
Tagged with:
-
I don't this is going to work. You are going to have duplicates of what is supposed to be Singletons (WrapDelphi, PythonEngine). It may work with run-time packages, but you would have to put all run-time packages in the same folder as the pyd files.
-
Have you followed the instructions at DelphiVCL4Python/samples/Installer at main · Embarcadero/DelphiVCL4Python (github.com) for delphivcl DelphiFMX4Python/samples/Installer at main · Embarcadero/DelphiFMX4Python (github.com) for delphifmx
-
I have used Python for many many years and really like the language. However it is slow. Really slow. And it does not use those damn CPU cores in my computer. If you look at Python (created in 1989) and Ruby (created in 1993), they have a lot in common and the same limitations. Ruby is also quite nice and there was a lot of buzz around it about 10-15 years ago, but the slowness almost killed the interest in the language. On the other hand, and in a hard to explain way, Python flourished. In an irreversible way. It is now the main programming language in schools and universities, including computer science degrees. It is here to stay for many years to come. Of course you can make python faster (Cython, using optimized python extension modules, multiprocessing etc.), but it takes an effort. The focus of python development has been two areas: type safety (kind of odd for a dynamic language) execution speed The two at some point may converge. There are a few developments regarding speed that offer some hope; Per interpreter Gil introduced in Python 12 (see https://en.delphipraxis.net/topic/10372-true-thread-parallelism-with-p4d-and-python-12). This is only accessible in embedded Python, using the python API. There were proposals to make it accessible through the interpreter, but were rejected in favour of the following developments. Experimental Just-in-Time (JIT) Compilation introduced in the coming Python 3.13 (so far, the speed improvements are negligible) Free threaded python (GIL-free) also introduced in python 3.13. Sounds good but it is incompatible with the GIL-enabled version of python. Extension modules are also incompatible and the two versions will be available in parallel, which sounds messy.
-
Just keep in mind [RSP-43423] Using {$WEAKLINKRTTI ON} causes access violation on TList<T>.IndexOf method - Embarcadero Technologies, See also
-
WrapDelphi now automatically exposes all events. However, there has been no release of delphivcl recently incorporating these changes. If you create a custom delphivcl using the latest sources you do not need your custom panel. Panel should expose the above events.
-
You don't need Parent = self. Otherwise that's the idea.
-
Real soon!
- 5 replies
-
- pyscripter
- openai
-
(and 1 more)
Tagged with:
-
You are posting on the General Help forum. Since your topic is related to P4D you will get a better response by posting such questions to the Python4Delphi forum. The pydfm file plays the role of the dfm file in delphi. The statement self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "MainForm.pydfm")) creates the controls and loads the design properties. Have a look at the demo DelphiVCL4Python/samples/DesignExport/SampleForm/MainForm.py at main · Embarcadero/DelphiVCL4Python (github.com) After the call to LoadProps, you can modify the controls. For example: self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "MainForm.pydfm")) self.Button1.Caption = 'New Caption' Will show Button1 with Caption = 'New Caption' You can assign python code to events (e.g self.Button1.OnClick = ) or customize the controls in any way you wish.
-
A unique feature of PyScripter is that, when you run a script, the python process is kept alive at the end of the run. For example if you run the script: a = 1 after running you can still see the value of a in the variables window and you can print its value by typing "a" in the interpreter window. This also allows post-mortem debugging (Run, Post Mortem). In Visual Studio, the form is destroyed, because the python process ends. With PyScripter, you have to explicitly destroy the form. To emulate the behaviour of other IDE's you could do Run, Reinitialize Python Engine at the end of each run. There were multiple request of emulating the PyScripter way in other IDEs (e.g. Access python console and program variables after program finished running? – IDEs Support (IntelliJ Platform) | JetBrains or if you google "python see variables after running").
-
Add f.Free() as the last statement of main() Then it should work as expected. Application.Free() instead of f.Free() should also work.
-
The latest version dropped support for python 3.7. Use a more recent version of python.
- 1 reply
-
- embedded
- windows 11 pro
-
(and 2 more)
Tagged with: