Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol not found in flat namespace #17

Closed
wobsoriano opened this issue Jul 4, 2022 · 9 comments
Closed

Symbol not found in flat namespace #17

wobsoriano opened this issue Jul 4, 2022 · 9 comments

Comments

@wobsoriano
Copy link

Hey, this is an awesome module! I am on M1 Pro and was getting this error:

node:internal/modules/cjs/loader:1187
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen(/Users/tmp/dalle-playground/node_modules/node-calls-python/build/Release/nodecallspython.node, 0x0001): symbol not found in flat namespace '_PyBool_Type'
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1187:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/tmp/dalle-playground/node_modules/node-calls-python/index.js:4:25)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Followed the installation instructions and installed the needed stuff. Copied the example usage.

Any help would be much appreciated!

@hmenyus
Copy link
Owner

hmenyus commented Jul 5, 2022

Could you share your OS, compiler version, python version and node/node-gyp version? Thanks

@wobsoriano
Copy link
Author

OS: Monterey 12.4 (21F79)
node-gyp version: v9.0.0
node version: v16.14.2
python version: 3.9.12
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@hmenyus
Copy link
Owner

hmenyus commented Jul 8, 2022

Could you run this and attach the output?
otool -l /Users/tmp/dalle-playground/node_modules/node-calls-python/build/Release/nodecallspython.node

@wobsoriano
Copy link
Author

wobsoriano commented Jul 10, 2022

Hi, thanks. I got this

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: 
can't open file: /Users/tmp/dalle-playground/node_modules/node-calls-python/build/Release/nodecallspython.node (No such file or directory)

@hmenyus
Copy link
Owner

hmenyus commented Jul 11, 2022

You may have deleted the file which is present in the error message above (dlopen(....))
Please search nodecallspython.node and run otool -l on that file. Thanks

@wobsoriano
Copy link
Author

So I switched to Node v18, and got this error instead

 node index
node:internal/modules/cjs/loader:1196
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen(/Users/wobsoriano/tmp/dalle-playground/node_modules/node-calls-python/build/Release/nodecallspython.node, 0x0001): tried: '/Users/wobsoriano/tmp/dalle-playground/node_modules/node-calls-python/build/Release/nodecallspython.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
    at Module._extensions..node (node:internal/modules/cjs/loader:1196:18)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/wobsoriano/tmp/dalle-playground/node_modules/node-calls-python/index.js:4:25)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.4.0

Looks like an architecture problem. I'm on M1 Pro

@hmenyus
Copy link
Owner

hmenyus commented Jul 18, 2022

Try to specify the arch for npm like these:
npm install --target_arch=arm64 node-calls-python
npm install --arch=arm64 --target_arch=arm64 node-calls-python

Honestly this problem is not related to the addon. Looks like node-gyp compiles for x64 but you run node arm64. Please also note that you need python for arm64 as well. Otherwise you may run rosetta2 to run x64 code on your M1 Pro.

@wobsoriano
Copy link
Author

npm install --target_arch=arm64 node-calls-python
npm install --arch=arm64 --target_arch=arm64 node-calls-python

Did the trick, thanks!

@changyongyong
Copy link

Try to specify the arch for npm like these: npm install --target_arch=arm64 node-calls-python npm install --arch=arm64 --target_arch=arm64 node-calls-python

Honestly this problem is not related to the addon. Looks like node-gyp compiles for x64 but you run node arm64. Please also note that you need python for arm64 as well. Otherwise you may run rosetta2 to run x64 code on your M1 Pro.

I am on M1 and was still getting this error:
node_modules/node-calls-python/build/Release/nodecallspython.node, 0x0001): symbol not found in flat namespace '_PyBool_Type'
at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1822)
at Module._extensions..node (node:internal/modules/cjs/loader:1226:18)
at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1822)
at Module.load (node:internal/modules/cjs/loader:1011:32)
at Module._load (node:internal/modules/cjs/loader:846:12)
at f._load (node:electron/js2c/asar_bundle:2:13330)
at Module.require (node:internal/modules/cjs/loader:1035:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/xx/workspace/gitlab/electron/demo/node_modules/node-calls-python/index.js:4:25)
at Module._compile (node:internal/modules/cjs/loader:1141:14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants