DEV Community

Andy Chong for PostCo

Posted on • Edited on

2 2

Solve node-gyp build error due to PYTHONPATH

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

DONE!


References

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay