question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: No module named gyp on Cygwin/Windows

See original GitHub issue

Keep getting below error when I run npm install --verbose to install my Node.js application, which is indirectly using node-gyp to compile re2 module. I’ve followed guidelines here

  • Python Version (please note I installed via Cygwin setup.exe):
$ /cygdrive/c/Python27/python.exe --version
Python 2.7.16
  • Node Version:
node -v
v11.9.0
 npm -v
6.9.0
  • Platform: Cygwin on Microsoft Windows 10 Enterprise
uname -a
CYGWIN_NT-10.0 TNJ10038LKVTJKF 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
  • Compiler: Using Microsoft Visual Studio 2017 Professional with Desktop development with C++" workload
  • Module: It’s failing when my app is trying to node-gyp compile re2 module
Verbose output from `npm install --verbose` command:
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\<myId>\\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   '--verbose' ]
npm info using npm@6.9.0
npm info using node@v11.9.0
npm verb npm-session 7378279f82bfc9e2
npm info lifecycle @data-leakage-protection/git-repo-inspector@1.1.0~preinstall: @data-leakage-protection/git-repo-inspector@1.1.0
npm timing stage:loadCurrentTree Completed in 6279ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 40ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 974ms
npm http fetch GET 200 https://registry.npmjs.org/@data-leakage-protection%2fsignatures 1287ms
npm http fetch GET 200 https://registry.npmjs.org/fs-extra 341ms
npm http fetch GET 200 https://registry.npmjs.org/re2 822ms
npm http fetch GET 200 https://registry.npmjs.org/fsevents 354ms
npm http fetch GET 200 https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz 950ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 7464ms
npm timing stage:loadIdealTree Completed in 9344ms
npm timing stage:generateActionsToTake Completed in 282ms
npm verb correctMkdir C:\Users\<myId>\\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using C:\Users\<myId>\\AppData\Roaming\npm-cache\_locks\staging-4c24b48be61e8043.lock for C:\git\ecom\git-repo-inspector\node_modules\.staging
npm http fetch GET 200 https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz 332ms
npm http fetch GET 200 https://registry.npmjs.org/re2/-/re2-1.8.4.tgz 651ms
npm http fetch GET 200 https://registry.npmjs.org/@data-leakage-protection/signatures/-/signatures-1.1.1.tgz 934ms
npm timing action:extract Completed in 1512ms
npm info lifecycle undefined~preuninstall: undefined
npm info lifecycle undefined~uninstall: undefined
npm info lifecycle undefined~preuninstall: undefined
npm info lifecycle undefined~uninstall: undefined
npm info lifecycle undefined~preuninstall: undefined
npm info lifecycle undefined~uninstall: undefined
npm info lifecycle undefined~preuninstall: undefined
npm info lifecycle undefined~uninstall: undefined
npm timing action:unbuild Completed in 7ms
npm timing action:remove Completed in 1ms
npm timing action:finalize Completed in 428ms
npm timing audit submit Completed in 2097ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 2098ms
npm timing audit body Completed in 5ms
npm timing action:refresh-package-json Completed in 418ms
npm info lifecycle fs-extra@7.0.1~preinstall: fs-extra@7.0.1
npm info lifecycle re2@1.8.4~preinstall: re2@1.8.4
npm info lifecycle @data-leakage-protection/signatures@1.1.1~preinstall: @data-leakage-protection/signatures@1.1.1
npm timing action:preinstall Completed in 1ms
npm info linkStuff fs-extra@7.0.1
npm info linkStuff re2@1.8.4
npm info linkStuff @data-leakage-protection/signatures@1.1.1
npm timing action:build Completed in 3ms
npm info lifecycle fs-extra@7.0.1~install: fs-extra@7.0.1
npm info lifecycle re2@1.8.4~install: re2@1.8.4

> re2@1.8.4 install C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2
> node-gyp rebuild


C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2>if not defined npm_config_node_gyp (node "C:\Users\<myId>\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "c:\Users\<myId>\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) 
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'c:\\Users\\<myId>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild' ]
gyp info using node-gyp@3.8.0
gyp info using node@11.9.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "c:\Python27\python.exe" in the PATH
gyp verb `which` succeeded c:\Python27\python.exe c:\Python27\python.exe
gyp verb check python version `c:\Python27\python.exe -c "import sys; print "2.7.16
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 11.9.0
gyp verb command install [ '11.9.0' ]
gyp verb install input version string "11.9.0"
gyp verb install installing version: 11.9.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 11.9.0
gyp verb build dir attempting to create "build" dir: C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\build
gyp verb build dir "build" dir needed to be created? C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\build
gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.17134
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64
gyp verb find vs2017   - Found Microsoft.VisualStudio.VC.MSBuild.Base
gyp verb find vs2017   - Using this installation with Windows 10 SDK
gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\config.gypi
gyp verb common.gypi checking for gypi file: C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn c:\Python27\python.exe
gyp info spawn args [ 'c:\\Users\\<myId>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\git\\ecom\\git-repo-inspector\\node_modules\\@data-leakage-protection\\signatures\\node_modules\\re2\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\Users\\<myId>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\<myId>\\.node-gyp\\11.9.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\<myId>\\.node-gyp\\11.9.0',
gyp info spawn args   '-Dnode_gyp_dir=c:\\Users\\<myId>\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\<myId>\\.node-gyp\\11.9.0\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\git\\ecom\\git-repo-inspector\\node_modules\\@data-leakage-protection\\signatures\\node_modules\\re2',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\git\\ecom\\git-repo-inspector\\node_modules\\@data-leakage-protection\\signatures\\node_modules\\re2\\build',
gyp info spawn args   '-Goutput_dir=.' ]
Traceback (most recent call last):
  File "c:\Users\<myId>\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py", line 13, in <module>
    import gyp
ImportError: No module named gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (c:\Users\v094303\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "c:\\Users\\v094303\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm verb lifecycle re2@1.8.4~install: unsafe-perm in lifecycle true
npm verb lifecycle re2@1.8.4~install: PATH: C:\Users\v094303\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2\node_modules\.bin;C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\.bin;C:\git\ecom\git-repo-inspector\node_modules\.bin;C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\Program Files (x86)\Python36-32\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\MySQL\MySQL Utilities 1.3.5;C:\Program Files (x86)\GitExtensions;C:\Program Files\PuTTY;C:\Program Files (x86)\Sennheiser\SoftphoneSDK;C:\Program Files\Redis;C:\Program Files\Git\cmd;C:\program files\Java\jre8\bin;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio;C:\Program Files\nodejs;C:\cygwin64\bin;C:\Users\v094303\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\MySQL\MySQL Utilities 1.3.5;C:\Program Files (x86)\GitExtensions;C:\Program Files\PuTTY;C:\Program Files (x86)\Sennheiser\SoftphoneSDK;C:\Program Files\Redis;C:\program files\Java\jre8\bin;C:\Users\v094303\AppData\Local\Microsoft\WindowsApps;C:\Maven\apache-maven-3.5.2\bin;C:\ProgramData\Visual Studio Code;C:\Users\v094303\AppData\Roaming\npm
npm verb lifecycle re2@1.8.4~install: CWD: C:\git\ecom\git-repo-inspector\node_modules\@data-leakage-protection\signatures\node_modules\re2
npm info lifecycle re2@1.8.4~install: Failed to exec install script
npm timing action:install Completed in 5548ms
npm verb unlock done using C:\Users\v094303\AppData\Roaming\npm-cache\_locks\staging-4c24b48be61e8043.lock for C:\git\ecom\git-repo-inspector\node_modules\.staging
npm timing stage:rollbackFailedOptional Completed in 578ms
npm timing stage:runTopLevelLifecycles Completed in 25352ms
npm WARN enoent ENOENT: no such file or directory, open 'C:\git\ecom\git-repo-inspector\node_modules\fsevents\package.json'
npm verb enoent This is related to npm not being able to find a file.
npm verb enoent 
npm WARN enoent ENOENT: no such file or directory, open 'C:\git\ecom\git-repo-inspector\node_modules\fsevents\node_modules\rc\package.json'
npm verb enoent This is related to npm not being able to find a file.
npm verb enoent 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64

npm verb stack Error: re2@1.8.4 install: `node-gyp rebuild`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (C:\Users\v094303\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
npm verb stack     at EventEmitter.emit (events.js:197:13)
npm verb stack     at ChildProcess.<anonymous> (C:\Users\v094303\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
npm verb stack     at ChildProcess.emit (events.js:197:13)
npm verb stack     at maybeClose (internal/child_process.js:978:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
npm verb pkgid re2@1.8.4
npm verb cwd C:\git\ecom\git-repo-inspector
npm verb Windows_NT 10.0.16299
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\v094303\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--verbose"
npm verb node v11.9.0
npm verb npm  v6.9.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2@1.8.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the re2@1.8.4 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 27439ms

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\v094303\AppData\Roaming\npm-cache\_logs\2019-06-18T12_03_59_895Z-debug.log

My npm config list settings:

npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.9.0 node/v11.9.0 win32 x64"

; project config C:\git\ecom\git-repo-inspector\.npmrc
package-lock = false
unsafe-perm = true

; userconfig C:\Users\v094303\.npmrc
https-proxy = "http://<redacted>.<redacted>.com:80/"
msvs_version = "2017"
node_gyp = "c:\\Users\\<myId>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
noproxy = ".<redacted>.com"
prefix = "C:\\Users\\<myId>\\\AppData\\Roaming\\npm"
proxy = "http://<redacted>.<redacted>.com:80/"
python = "c:\\Python27\\python.exe"

; builtin config undefined
prefix = "C:\\Users\\<myId>\\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\git\ecom\git-repo-inspector
; HOME = C:\Users\<myId>\
; "npm config ls -l" to show all defaults.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bzozcommented, Jun 26, 2019

From the linked code fix I would guess under Cygwin sys.argv[0] does not include the full path to the script. Maybe using abspath:

sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'pylib'))

will fix this?

@joquijada I don’t have Cygwin, could you test this? This also would be a nice first PR 😃

1reaction
rvaggcommented, Jun 21, 2019

K, I’ll leave this open for a bit longer in case one of our windows experts has the bandwidth to have a look and has some idea, be warned that there’s limited bandwidth available around here and it’s not uncommon for more obscure issues to go unanswered. Mostly this issue tracker is a cross-your-fingers kind of deal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenShift : ImportError: No module named gyp: on NodeJs ...
This error started to happen for me suddenly, too, even though it had worked before. For some reason the Python gyp module is...
Read more >
Node installation: No module named gyp.common
I just did a fresh git checkout of and it configures with both python 2.6 and 2.7. What ./configure is failing to find...
Read more >
sitemap-questions-3.xml - Super User
... -i-get-this-error-import-error-no-module-named-request-what-to-d 2019-02-21 ... https://superuser.com/questions/1405037/windows-10-node-gyp-error-while- ...
Read more >
T213944 Jenkins jobs for npm-test fail on project with deps on ...
... ImportError: No module named compiler.ast gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack...
Read more >
How to Fix ImportError: No module named pandas [Mac/Linux ...
Quick Fix: Python raises the ImportError: No module named pandas when it cannot find the Pandas installation. The most frequent source of this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found