embedPy installation: os error with kdb and python

75 Views Asked by At

I'm trying to install embedPy on my machine, but I'm getting an os error.

For more info, here's the link: https://github.com/KxSystems/embedpy

I am thinking of installing embedPy on my local machine by downloading and installing the 1.5 version release.

According to the instructions, after I unzip the latest version, I try to run the tests by running "q test.q", and then I get the following error:

C:/q/help.q
C:/q/c/odbc.k
C:/q/ps.k
'os
  [7]  \python -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"2>nul <nul
       ^
q.p))

I don't understand the os error and I was wondering if anyone has experienced this before. If so, do you know what the problem is? Maybe it's a specific python version?

I have Python v3.9 and kdb v4.0


To respond to rianoc's answer:

I tried both methods, and they give me the same answer. As you can see below, it's interesting that python is located, but can't perform the function:

q)system"where python3"
"C:\\Users\\a623868\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe"
q)system"where python"
"C:\\Users\\a623868\\AppData\\Local\\Programs\\Python\\Python39\\python.exe"
"C:\\Users\\a623868\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe"
"C:\\Users\\a623868\\AppData\\Local\\Programs\\Spyder\\Python\\python.exe"
q)system"python3 -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
'os
  [1]  \python3 -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"
       ^
q))system"python -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
Traceback (most recent call last):
  File "C:\Users\a623868\AppData\Local\anaconda3\Lib\io.py", line 54, in <module>
ImportError: cannot import name 'text_encoding' from 'io' (unknown location)
'os
  [4]  \python -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"

Do you know why python is not found when the first two commands show that python is installed?


After uninstalling anaconda, I get the following:

q)system"where python3"
"C:\\Users\\a623868\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe"
q)system"where python"
"C:\\Users\\a623868\\AppData\\Local\\Programs\\Python\\Python39\\python.exe"
"C:\\Users\\a623868\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe"
"C:\\Users\\a623868\\AppData\\Local\\Programs\\Spyder\\Python\\python.exe"
q)system"python3 -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
'os
  [1]  \python3 -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"
       ^
q))system"python -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
"3.9"

Now when I run test.q, I get a different error, but at least it's progress:

q test.q
KDB+ 4.0 2022.01.14 Copyright (C) 1993-2022 Kx Systems
++++++++++++++++++++++++++++++++++++++++++++++++++++
Loading custom startup.  Customize in C:/q/q.q
Start timestamp (local): 2024.03.26D10:48:22.584873000
Full display precisions: \P 0
C:/q/help.q
C:/q/c/odbc.k
C:/q/ps.k
'libpython
  [5]  M:\mmv456\embedPy_windows-1.5.0\p.q:14:
 .P.env:not H~P;
 .p:(`:./p 2:(`init;3))[L;H;B]]
    ^

Will be looking into the error above...

1

There are 1 best solutions below

4
rianoc On

embedPy needs to make a call to Python.

It tests python3 first and if that fails it tries python.

You can test on your command prompt to check if they run:

C:\Users\rianoc>where python3
C:\Users\rianoc\AppData\Local\Microsoft\WindowsApps\python3.exe

C:\Users\rianoc>where python
C:\Users\rianoc\AppData\Local\Microsoft\WindowsApps\python.exe

C:\Users\rianoc>python3 -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"
3.11

C:\Users\rianoc>python -c "print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));"
3.11

These can also be tested from q:

q)system"where python3"
"C:\\Users\\rianoc\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe"

q)system"where python"
"C:\\Users\\rianoc\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe"

q)system"python3 -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
"3.11"

q)system"python -c \"print('.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']]));\""
"3.11"