# How to run .py in KX Developer

**URL:** <https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655>\
**Category:** Community Support\
**Tags:** imported, other\
**Created:** [October 24, 2022, 12:00am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655 "2022-10-24T00:00:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![evol](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@evol](https://forum.kx.com/u/evol)\
**Post date:** [October 24, 2022, 12:00am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/1 "2022-10-24T00:00:00Z")

</div>

[https://learninghub.kx.com/forums/topic/how-to-run-py-in-kx-developer](https://learninghub.kx.com/forums/topic/how-to-run-py-in-kx-developer)

Hi community

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

**error: embedPy must be loaded to evaluate Python code**

&nbsp;

My version in Conda base env

kdb 4.0

embedPy 1.5

jupyterq 1.1.13

python 3.9.12

&nbsp;

that’s my terminal code for q

&nbsp;

&nbsp;

that’s my code for Kx developer

&nbsp;

&nbsp;

So, how can I fix it?

thanks all

&nbsp;

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

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [October 24, 2022, 12:00am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/2 "2022-10-24T00:00:00Z")

</div>

Have you installed embedpy?

[https://code.kx.com/q/ml/embedpy/#build-and-install](https://code.kx.com/q/ml/embedpy/#build-and-install")

Can you load and test it?

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

&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [November 10, 2022, 12:00am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/3 "2022-11-10T00:00:00Z")

</div>

There are useful comparisons on this page: [https://code.kx.com/pykx/1.3/comparisons.html](https://code.kx.com/pykx/1.3/comparisons.html")

&nbsp;

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](https://github.com/rianoc/qXML")

&nbsp;

kdb+ can also use websockets natively if needed

[https://code.kx.com/q/wp/websockets/](https://code.kx.com/q/wp/websockets/")

---

<div class="post-metadata">

**Author:** ![evol](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@evol](https://forum.kx.com/u/evol)\
**Post date:** [October 24, 2022, 12:00am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/4 "2022-10-24T00:00:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gregbowers](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@gregbowers](https://forum.kx.com/u/gregbowers)\
**Post date:** [March 14, 2024, 7:46am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/5 "2024-03-14T07:46:48Z")

</div>

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

stevediaz[salesforce cpq](https://www.igmguru.com/salesforce/salesforce-cpq-training/)

---

<div class="post-metadata">

**Author:** ![marcosandrew](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@marcosandrew](https://forum.kx.com/u/marcosandrew)\
**Post date:** [April 23, 2024, 11:03am UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/6 "2024-04-23T11:03:48Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Lingli](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@Lingli](https://forum.kx.com/u/Lingli)\
**Post date:** [April 29, 2024, 5:59pm UTC](https://forum.kx.com/t/how-to-run-py-in-kx-developer/13655/7 "2024-04-29T17:59:20Z")

</div>

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