hmenyus / node-calls-python

Call Python from NodeJS directly in-process without spawning processes
MIT License
252 stars 26 forks source link

Not working with Python virtual environments #58

Closed toncho11 closed 1 year ago

toncho11 commented 1 year ago

I am on Windows 10. My project is in a virtual Python environment with certain packages installed. node-calls-python tries to find the real python as it is searching for the "libs" folder that contains *.lib files. The problems is that when it is installed into the real python then it does not know about any of the modules I have installed in my Python environment. node-calls-python should take into account if it is executed from virtual environment and install itself accordingly so that other modules in this environment are accessible.

Thank you.

hmenyus commented 1 year ago

please see the updated readme: https://github.com/hmenyus/node-calls-python#using-python-venv

toncho11 commented 1 year ago

Hi. Thank you for your quick response!

Now I do not get a missing package, but another error:

(eyelink) C:\Work\javascript\emool\src\testing\python_eyelink>node test_server.js
node:internal/modules/cjs/loader:1327
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: \\?\C:\Work\javascript\emool\src\testing\python_eyelink\node_modules\node-calls-python\build\Release\nodecallspython.node is not a valid win32 application.
\\?\C:\Work\javascript\emool\src\testing\python_eyelink\node_modules\node-calls-python\build\Release\nodecallspython.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1327:18)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (C:\Work\javascript\emool\src\testing\python_eyelink\node_modules\node-calls-python\index.js:4:25)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v20.6.1

So now it is similar to: https://github.com/hmenyus/node-calls-python/issues/57

I am on Windows 10, Python 3.8, nodejs 20.6.1 and in a virtual environment "eyelink".

hmenyus commented 1 year ago

not sure, but it looks like you may run 32 bit node, but the addon was built for 64bit or 64bit node with 32bit addon.