KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Solutions How to run .py in KX Developer

  • How to run .py in KX Developer

    Posted by evol on October 24, 2022 at 12:00 am

    Hi community

    My problem is:” I can’t open .py in KX Developer.”

    error: embedPy must be loaded to evaluate Python code

     

    My version in Conda base env

    kdb 4.0

    embedPy 1.5

    jupyterq 1.1.13

    python 3.9.12

     

    that’s my terminal code for q

     

     

    that’s my code for Kx developer

     

     

    So, how can I fix it?

    thanks all

     

    Can I use python to call a q database? Or using q to compute python data in the same dialog box?

    Lingli replied 7 months, 3 weeks ago 5 Members · 6 Replies
  • 6 Replies
  • rocuinneagain

    Member
    October 24, 2022 at 12:00 am

    Have you installed embedpy?

    https://code.kx.com/q/ml/embedpy/#build-and-install

    Can you load and test it?

    \l p.q 
    p)print(1+1)

     

  • evol

    Member
    October 24, 2022 at 12:00 am

    It’s work, thanks

    Also, I have 3 questions

    01/ just like before python code, I download data from ibapi api

    I can use q insert to q databases ? in the same dialog box or not ?

    Can you give a simple example of Q and PYTHON  code

    02/ or use python to select data from q databases to trade?

    03/ What’s different about embedPy and PYQ?

    thanks

  • rocuinneagain

    Member
    November 10, 2022 at 12:00 am

    There are useful comparisons on this page: https://code.kx.com/pykx/1.3/comparisons.html

     

    You can expose python function to q using embedpy

    You can do it all in a q file or as I like to do split out to a .py and a .q

    Such as: https://github.com/rianoc/qXML

     

    kdb+ can also use websockets natively if needed

    https://code.kx.com/q/wp/websockets/

    • gregbowers

      Member
      March 14, 2024 at 7:46 am

      you’re encountering an issue with running Python scripts in KX Developer due to the embedPy module not being loaded.

      To resolve this issue, you need to ensure that embedPy is properly loaded in your KDB environment. You can do this by adding the following line to your q script before attempting to run any Python code:

      \l embedPy.q

      This line loads the embedPy module, allowing you to evaluate Python code within your q environment.

      Once embedPy is loaded, you should be able to run Python scripts in KX Developer without encountering the error you mentioned.

      Regarding your question about using Python to call a q database or vice versa, yes, it’s possible to integrate Python and q. You can use embedPy to call Python functions from q or vice versa. This allows you to leverage the strengths of both languages within the same environment.

      Thank you

      stevediazsalesforce cpq

  • marcosandrew

    Member
    April 23, 2024 at 11:03 am

    Hey Members,

    I was also facing this situation that I also couldn’t run .py in KX Developer but my problem got solved by the solutions by @rocuinneagain and @gregbowers .

    Thank you for sharing such solutions mates.

    (Marcos)

  • Lingli

    Member
    April 29, 2024 at 5:59 pm

    can someone here screenshot the whole process of installing kx developer in cmd windows? help help help🙏

Log in to reply.