Feng Deng
Feng Deng

Reputation: 153

node-gyp: gyp ERR! cannot load shared libpython2.7.so.1.0

I am trying to build the hello world c++ addon for node js. Both node.js and node-gyp seem have been installed successfully into a redhat linux. However when I ran "node-gyp configure", it gave the following error. I failed to get any insightful information by gooling as well as from the wiki page. Can you please kindly advise?

I built the python from source and had a customized installation. And libpython2.7.so.1.0 is presented in the following:$PYTHONPATH as well as $LD_LIBRARY_PATH. Does node or node-gyp search a rather different environment virable for shared libraries?

Thanks in advance.

Stack Error:

~/examples/node.js/my_node_addon-1[13:14]% node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp\@0.10.10
gyp info using node\@0.10.18 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: python: error while loading shared libraries:      libpython2.7.so.1.0: cannot open shared object file: No such file or directory
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:637:15)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at maybeClose (child_process.js:735:16)
gyp ERR! stack     at Socket.<anonymous> (child_process.js:948:11)
gyp ERR! stack     at Socket.EventEmitter.emit (events.js:95:17)
gyp ERR! stack     at Pipe.close (net.js:466:12)
gyp ERR! System Linux 2.6.18-194.32.1.el5
gyp ERR! command "node" "/work/dengf/conf/bin/node-gyp" "configure"
gyp ERR! cwd /home/dengf/examples/node.js/my_node_addon
gyp ERR! node -v v0.10.18
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok

But when I run python alone it loads the shared lib just fine:

~/examples/node.js/my_node_addon-1[13:14]% python -V
Python 2.7.3

Also, my binding.gyp is as below:

{
    'targets': [
        {
            'target_name': 'hello',
            'sources': [ 'src/hello.cc' ],
            'include_dirs': ['/path/to/my/include'],
            'link_settings': {
                'library_dirs': [
                    '/path/to/my/libpython2.7.so.1.0'
                ]
            }
        }
    ]
}

Upvotes: 2

Views: 1086

Answers (1)

Feng Deng
Feng Deng

Reputation: 153

Finally, after 2 days of consecutive tracing and debugging, I had this sorted. However, I am not sure if this is due to my customized installation of Python. I updated the code below in ~node_modules/node-gyp/lib/configure.js (changed original as in commented line 93 to 94:

93     // var env = { TERM: 'dumb', PATH: process.env.PATH};
94     var env = process.env;

I will truly appreciate if any node.js experts in the group can help with a rational with the above change?

I also posted this question on google group nodejs, so FYI.

Thanks again Feng

Upvotes: 2

Related Questions