No module named gyp.common - 全栈笔记

No module named gyp.common

任亦伟 Nodejs 2015-03-26 262 次浏览 没有评论

I was trying to install node.js on CentOS 6.4 VirtualBox guest on a Windows XP host with the following commands:

1
2
cd /usr/local/src/
3
git clone git://github.com/joyent/node.git
4
cd node
5
./configure
6
make
7
make install
8

I only reached as far as ./configure. When I executed ./configure I got the following errors:
1
2
Traceback (most recent call last):
3
File "./configure", line 14, in
4
<module> from gyp.common import GetFlavor
5
ImportError: No module named gyp.common
6

The ./configure calls Python, which you already do have installed (the Traceback message is from a working Python).
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 is Generate Your Progject, which should be included in the tools/gyp directory.
If those files are not there, git might have missed a beat.
This can also be caused by a different gyp module, than the one provided in node.js, being found by python. To check that you can do

1
2
$ python
3
>>> import gyp
4
>>> print gyp.__file__
5

if you don’t get an ‘ImportError’ this shows you which file Python actually imports.

I think something is either wrong with your clone copy of node.js or something is up with the mix of packages you have installed on your CentOS 6.4 box. I have that same distro here and I just did the same steps you did and it worked.

01
02
$ ./configure
03
{ 'target_defaults': { 'cflags': [],
04
                       'default_configuration': 'Release',
05
                       'defines': [],
06
                       'include_dirs': [],
07
                       'libraries': []},
08
  'variables': { 'clang': 0,
09
                 'gcc_version': 44,
10
                 'host_arch': 'x64',
11
                 'node_install_npm': 'true',
12
                 'node_prefix': '',
13
                 'node_shared_cares': 'false',
14
                 'node_shared_http_parser': 'false',
15
                 'node_shared_libuv': 'false',
16
                 'node_shared_openssl': 'false',
17
                 'node_shared_v8': 'false',
18
                 'node_shared_zlib': 'false',
19
                 'node_tag': '',
20
                 'node_unsafe_optimizations': 0,
21
                 'node_use_dtrace': 'false',
22
                 'node_use_etw': 'false',
23
                 'node_use_openssl': 'true',
24
                 'node_use_perfctr': 'false',
25
                 'node_use_systemtap': 'false',
26
                 'python': '/usr/bin/python',
27
                 'target_arch': 'x64',
28
                 'v8_enable_gdbjit': 0,
29
                 'v8_no_strict_aliasing': 1,
30
                 'v8_use_snapshot': 'true'}}
31
creating  ./config.gypi
32
creating  ./config.mk
33

As @Anthon suggested I ran the following commands and I don’t even have the gyp.common Python package installed either when I ran the above ./configure command, and yet it worked fine.
01
02
$ python
03
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) 
04
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
05
Type "help", "copyright", "credits" or "license" for more information.
06
>>> import gyp
07
Traceback (most recent call last):
08
  File "<stdin>", line 1, in <module>
09
ImportError: No module named gyp
10

So I’m not really sure what’s going on with your environment. I would debug it a little bit further and take a look at your $PATH and $LD_LIBRARY_PATH environment variables to determine if you’re getting the version of Python that you think you are.
workaround
If you don’t require the latest node.js you can just install it from the yum repositories for CentOS 6.4. Most of the Node.js toolset is already pre-built for you in the EPEL repository, which you should have by default. So just run this command to install it:
1
2
$ sudo yum install nodejs
3

All the other packages are available if you do search for nodejs.
01
02
$ yum search nodejs
03
Loaded plugins: fastestmirror, priorities, refresh-packagekit
04
Loading mirror speeds from cached hostfile
05
 * base: mirrors.liquidweb.com
06
 * epel: mirror.steadfast.net
07
 * extras: mirror.thelinuxfix.com
08
 * updates: centos.mbni.med.umich.edu
09
73 packages excluded due to repository priority protections
10
======================================================= N/S Matched: nodejs ========================================================
11
nodejs-burrito.noarch : Wrap up expressions with a trace function while walking the AST
12
nodejs-delayed-stream.noarch : Buffers events from a stream until you are ready to handle them
13
nodejs-npm-registry-client.noarch : Client for the npm registry
14
nodejs-options.noarch : Light-weight in-code option parser for nodejs
15
nodejs-osenv.noarch : Look up environment settings specific to different operating systems
16
...
17
...
18

发表评论

回顶部