loading...
PostCo

Solve node-gyp build error due to PYTHONPATH

andychongyz profile image Andy Chong Updated on ・1 min read

Update

From node-gyp@5.1.0 onwards, python3 will be used for the build, therefore please follow the steps below, but replace the last step with

PYTHONPATH=python3 && npm i

Recently, I faced the problem where node-gyp rebuild failed due to PYTHONPATH is pointing to python3. This is due to python2 is being deprecated, and python now points to python3 by default. While node-gyp requires python2 to build.

To solve this on macOS, just make sure you reinstall python 2 and python 3 and point PYTHONPATH environment variable to python2.

# Only do this if `where python2` output nothing
brew uninstall --ignore-dependencies python2 python3
brew install python2 python3 


PYTHONPATH=python2 && npm i

DONE!


References

Posted on Feb 7 by:

andychongyz profile

Andy Chong

@andychongyz

I'm a software engineer working in PostCo. And we're hiring @ postco.co/careers!

PostCo

PostCo provides a convenient way to collect and return online purchases at nearby local stores instead of the Post Office. We are currently running the largest parcel collection and return network in Southeast Asia across MY, SG and VN.

Discussion

markdown guide