Jump to content

Search the Community

Showing results for tags 'python4delphi'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 10 results

  1. Greetings, I have several pieces of Python code that checks one condition in a loop, if it is met, it outputs Print, if not waits 5 seconds and checks again, and so on endlessly. How do I stop the script using delphi? Can I somehow send ctrl+c or something like that there. The answer from Demo33 did not fit v - 3.12.dll
  2. carlosanduj

    Error import pandas

    Hello everyone I'm starting to develop an application with Python4delphi and have run into a problem. The Python4delphi demos work correctly and I can communicate with python. The problem appears when I go to run import pandas as pd When I do this it shows me this error: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\__init__.py", line 59, in <module> from pandas.core.api import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\api.py", line 47, in <module> from pandas.core.groupby import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module> from pandas.core.groupby.generic import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\generic.py", line 67, in <module> from pandas.core.frame import DataFrame File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py", line 142, in <module> from pandas.core.generic import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py", line 187, in <module> from pandas.core.window import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window\__init__.py", line 1, in <module> from pandas.core.window.ewm import ( File "C:\Users\Carlos\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window\ewm.py", line 11, in <module> import pandas._libs.window.aggregations as window_aggregations ImportError: DLL load failed while importing aggregations: No se puede encontrar el módulo especificado. I have no problems with other imports like sys, os or matplotlib. The curious thing is that import pandas works correctly from the python console. I have uninstalled pandas and reinstalled it even downgrading the version and I can't solve it. On a colleague's PC with the same installation that I have, everything works perfectly. Does it occur to you what could be happening? Thank you very much for your time Carlos
  3. shineworld

    DelphiVCL and asyncio

    Hi all, it is possible to use the asyncio with a DelphiVCL ui-based program? I've implemented an asyncua Client to get data from an OPC UA Server. Here is a simple program that prints some values collected from an OPC UA server. """CNC OPC UA Client.""" #------------------------------------------------------------------------------- # Name: cnc_opcua_client # # Purpose: CNC OPC UA Client # # Note Checked with Python 3.11.3 # # Coding Style https://www.python.org/dev/peps/pep-0008/ #------------------------------------------------------------------------------- import time import asyncio import logging from asyncua import Client # == opc ua client settings == OPC_UA_SERVER_URL = "opc.tcp://localhost:4840/" OPC_UA_SERVER_URI = "https://www.someone.com/opc-ua/server" OPC_UA_ASYNC_SLEEP_TIME = 0.01 # == deveopment settings == DEBUG_LEVEL = logging.CRITICAL # avoid any log not critical DEBUG_ENABLED = False # creates a logger logger = logging.getLogger(__name__) async def main(): """Main entry point.""" # creats opc ua client in with-exception-handled block async with Client(url=OPC_UA_SERVER_URL) as client: # gets namespace index idx = await client.get_namespace_index(OPC_UA_SERVER_URI) # gets program position node program_position_node = client.get_node("ns=2;s=CNC.ProgramPosition") # server updating loop while True: # does nothing, just process relax await asyncio.sleep(OPC_UA_ASYNC_SLEEP_TIME) # reads and prints program positions value = await program_position_node.read_value() print('X:{:10.3f}, Y:{:10.3f}, Z:{:10.3f}'. format(value[0], value[1], value[2])) # checks if this module is running as the main program if __name__ == "__main__": logging.basicConfig(level=DEBUG_LEVEL) asyncio.run(main(), debug=DEBUG_ENABLED) Getting: *** Remote Interpreter Reinitialized *** X: 51.206, Y: 0.000, Z: 0.000 X: 51.206, Y: 0.000, Z: 0.000 X: 51.206, Y: 0.000, Z: 0.000 X: 51.206, Y: 0.000, Z: 0.000 At this point I would like to create a fashioned UI using DelphiVCL, but I'm unable to understand where to place the asyncio.run(main(), debug=DEBUG_ENABLED) because to get DelphiVCL UI the main loop is already done by Application.Run() call: # initializes GUI Application Application.Initialize() Application.Title = "OPC UA Client Demo" # creates main application form app = DesktopView(Application) app.Show() FreeConsole() # enters in vcl main loop Application.Run() # frees main application form app.Destroy() Thanks in advance for any suggestion. Best Regards Silverio
  4. hi i working to a project that need run python function in delphi. i use python4delphi and writed some codes but that not worked properly. If anyone knows the answers to these questions, I would be very grateful if they would give me the answers 1- How to call a python function with array of double as argument through Python4Delphi and receive the result of the function, which type is array of doubles, in Delphi. 2- Is it possible to import numpy,scipy,... just once and not need to import them every time i call the python function function sLineBreak := #13#10; Script := 'import numpy as np' + sLineBreak + 'def CCalcCustomRegr(args):' + sLineBreak + ' some python code.......' + sLineBreak + ' return result '+ sLineBreak; i need call CCalcCustomRegr with array of doubles as argument. and get result value which is array of doubles type.
  5. I am slightly confused about which repository of python4delphi is most correct to use to integrate Python into my Delphi applications. To date, I know of two repositories on which constant work is visible: - https://github.com/pyscripter/python4delphi - https://github.com/Embarcadero/python4delphi Comparing them it seems that they are managed by different people, but both make fixes and new features with quite a lot of activity, so they are both "alive." Does anyone know how this is organized and which one is preferable to use? Thanks in advance for the answers.
  6. Hi, 1. Is there a discord discussion group link that i can join ? ( i found one , https://discord.com/channels/989230637342933042/990834240608415834 , this is a correct forum related to this topic ?) 2. i have this simple python code, in the attached file , main.py - i wish to use a simple memo, 2 buttons (one for start_bot another for stop_bot) and when python4delphi component will read and execute script from main.py and add message receive from Telegram bot into the memo1. i have defined the following in delphi beside the main.py, 1. a pythonEngine and a pythonGUIInputOut component and set the relevant properties, i.e. IO to memo1. etc. 2. i have in my start_button try to executeStrings( memo1.lines) , but no result display my problem is i am unable to get the updates from the python , telegram bot , message receive into the Delphi(10.3)'s Form memo1. and i not even sure whether the bot is running. I have tested to run the python code. (in python 3.9) environment, it ran as expectedly. i am thinking to use the wrapDelphi to wrap the memo1 to the main.py by importing the memo1 component into the python script to add messages or clearing the memo1.lines , can any one help me by giving some advise , what do think i need to do or is wrapping the delphi memo1 component and change my python function i.e. echo() , handle_json() to change the content of the wrapped delphi's memo1.lines in the python code ? Thanks. main.py
  7. Hi all, I would like to add, to a python4delphi module, a getter method which return a 'dict'. For example: > import pycnccore1 as pyc >cnc_core = pyc.CNCCore() >print(cnc_core.paths) {'user_path': 'c:\\xyz', 'machine_path': 'd:\\machine_test', and so on} I don't know how to create a Delphi type to contain the dictionary and convert it to a Python dict as a result of the getter method. function TPyCNCCore.GetPaths(AContext: Pointer): PPyObject; begin Adjust(@Self); var PathDict: <i_do_not_know>; PathDict.Append('user_path', Self.UserPathString); PathDict.Append('machine_path', Self.MachinePathString); ... and so on ... Result := GetPythonEngine.VariantAsPyObject(PathDict); end; class procedure TPyCNCCore.RegisterGetSets(PythonType: TPythonType); begin inherited; with PythonType do begin PythonType.AddGetSet('paths', @TPyCNCCore.GetPaths, nil, 'Returns the used paths', nil); end; end; Thanks in advance for your suggestions Silverio
  8. Albion

    Calculation problem

    Good afternoon, I encountered such a problem, when executing a python script, the calculations are not written to the output fields, and therefore cannot go further, since they take values from them. Can anyone tell me what I did wrong?
  9. Good afternoon, I wanted to know if it is possible to get some information about Python4Delphi, except for two webinars, maybe there are some books, video tutorials, analyzes of all this. I really liked the ability to use Python in Delphi, but as I'm still new to this business, it's quite difficult for me to figure it out without instructions / tutorials / books. If you have the opportunity to share something that may be useful in the study of this topic, I will be incredibly grateful to you.
  10. Hi all. I'm trying to create a Python Extension Module with Delphi Sydney. I'm adding an IPC Engine Client to access to one or more IPC Engine Server (either based on Windows Messages). It works and is very a good tool. I've only a question about the resulting python class that does not have a list of properties/methods, not in all cases. Looking at xxx.__dir__ I can get the list of available methods: But if I use the code completion of PyScripter only base TPyDelphiPersistent are available: Strangely if I create a pre-made istance TPyIPCEngineClient object and I add it to the module as SetVar('myIPC', xxxx, xxx) all TPyIPCEngineClient are showed. What I'm mistaking ? Thank you in advance for replies. pycncipc1.zip
×