how to add path with module to python?
Asked Answered
M

5

9

I try to build V8 javascript engine. When I try to invoke the command python build/git_v8, I get error:

File build/gyp_v8, line 48 in < module >
     import gyp
ImportError: No module named GYP

How I can tell python where search GYP module and what is the correct path to the module in the folder GYP?

My version of python is 2.6.2.2, recommended in build instructions.

Manicurist answered 17/7, 2013 at 17:25 Comment(6)
just do pip install pyv8Aorist
see code.google.com/p/v8/wiki/BuildingWithGYPDiscomposure
@JoranBeasley: Where to call pip install pyv8?Amalita
from your terminal window ... you need setuptools if you dont already have it...Aorist
@JoranBeasley ah, didn't knew pip and it wasn't installed. sadly, this was no solution for me. thanks anywayAmalita
it might be different versions of python installed and full path specified in py file at #!/usr/bin/pythonArdel
X
4

Obviously, the module gyp.py is not in the search path of modules (sys.path). sys.path is an array variable in sys module which contains all known paths of the modules. You can add the directory containing the module gyp.py manually by either of these methods:

  1. set via PYTHONPATH environment variable (see http://docs.python.org/3/using/cmdline.html?highlight=path#envvar-PYTHONPATH)

  2. Add the path manually within your python script prior to importing gyp. For example, if the directory containing this module is /home/you/gyp:

import os, sys
sys.path.append('/home/you/gyp')

import gyp
#--------- That's it ------------

You can check if this path already exists using the debug lines

import sys
print(sys.path) # version python 3.2

or

print sys.path # version python 2.7
Xenophobia answered 13/11, 2013 at 20:10 Comment(0)
T
8

Install the module will be fine.

git clone https://chromium.googlesource.com/external/gyp
cd gyp
sudo ./setup.py install

enjoy it.

Towroy answered 20/10, 2014 at 5:4 Comment(1)
or just easy_install -U gypArdel
X
4

Obviously, the module gyp.py is not in the search path of modules (sys.path). sys.path is an array variable in sys module which contains all known paths of the modules. You can add the directory containing the module gyp.py manually by either of these methods:

  1. set via PYTHONPATH environment variable (see http://docs.python.org/3/using/cmdline.html?highlight=path#envvar-PYTHONPATH)

  2. Add the path manually within your python script prior to importing gyp. For example, if the directory containing this module is /home/you/gyp:

import os, sys
sys.path.append('/home/you/gyp')

import gyp
#--------- That's it ------------

You can check if this path already exists using the debug lines

import sys
print(sys.path) # version python 3.2

or

print sys.path # version python 2.7
Xenophobia answered 13/11, 2013 at 20:10 Comment(0)
U
2

I don't have enough reputation to comment -- but as @chrylis reported above -- links change. The new link for git'ing gyp is: https://chromium.googlesource.com/external/gyp.git if anyone else is hunting. Other than that -- the installation worked for me.

Undulant answered 2/7, 2015 at 1:6 Comment(0)
H
1

If you choose to install the module, notice the google source url has changed.

git clone https://chromium.googlesource.com/experimental/external/gyp
cd gyp
sudo ./setup.py install
Herminiahermione answered 3/2, 2016 at 9:18 Comment(0)
M
0

Gyp is a custom build tool by Google. The instructions at https://code.google.com/p/v8/wiki/BuildingWithGYP should be helpful.

Go to the root of the V8 checkout or source directory, and run

svn co http://gyp.googlecode.com/svn/trunk build/gyp

Mycosis answered 6/12, 2013 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.