ImportError: No module named Scripting #48

Closed
aliasone opened this Issue Dec 25, 2011 · 13 comments

Projects

None yet
@aliasone

I've installed 0.6.6 with n and I'm getting this error when trying to build node-serialport. Any ideas?

Traceback (most recent call last):
File "/opt/local/bin/node-waf", line 14, in
import Scripting
ImportError: No module named Scripting

node 0.6.6
npm 1.1.0-beta-4

Thanks!

@cwoelk
cwoelk commented Feb 1, 2012

To workaround this you probably can link the wafadmin directory from the correct version to /usr/local/lib/node.
I.E from within the latter directory with: ln -s /usr/local/n/versions/0.6.6/wafadmin/

@vgrichina

I'm also having this issue with 0.6.9

@vgrichina

cwoelk, your suggestion worked, thanks!

However you need to run ln -s /usr/local/n/versions/0.6.6/wafadmin (i.e. without the trailing slash)

@vgrichina vgrichina added a commit to vgrichina/n that referenced this issue Feb 3, 2012
@vgrichina vgrichina Fix for #48 ImportError: No module named Scripting
Creating link for wafadmin folder in $N_PREFIX/lib/node/
ca0930a
@shermany

I too am having this problem, however I think the fix vgrichina provided has one issue: It will work the first time it creates the symlink, but if you switch around node versions, it complains that the symlink already exists.

@fijiaaron

Here's an ugly script that adds the proper symlink:

# find the current version of node.js
NODE_VERSION=`node -v | sed s/^v//`

# find Scripting.py for the current version of node under the lib/node/wafadmin folder (it might be somewhere else though)
SEARCHROOT=/
SCRIPTING=`find $SEARCHROOT -name Scripting.py 2>/dev/null | grep $NODE_VERSION | grep "lib/node/wafadmin"`
# Needless to say, this is a really inefficient and fragile script.  
# It could be a bit more efficient if we didn't have to search the whole filesystem.


# find the wafadmin directory by getting the directory that Scripting.py is in
WAFADMIN=`dirname $SCRIPTING`

# find the directory that node-waf is in 
NODE_WAF=`which node-waf`
NODE_DIR=`dirname node-waf`

# create a symlink to the wafadmin directory that is relative to node-waf 
ln -s $WAFADMIN $NODE_DIR/../lib/node/wafadmin
@fijiaaron

The problem is that it needs to recursively copy lib/node and lib/node_modules
Why doesn't n use symlinks instead of copy?
You'll need to remove symlinks too.
And use current instead of the specific version

install_node() {
  local version=$1; shift
  local config=$@
  check_current_version

  # remove "v"
  version=${version#v}

  # activate

  for link = $NPREFIX
  if test -e $N_PREFIX/lib/nod; then
      rm $N
  if test -d $dir; then
    for PATH in bin/node bin/node-waf bin/npm lib/node lib/node_modules
    do
      echo $N_PREFIX/$PATH
      if test -e $N_PREFIX/$PATH; then
        rm $N_PREFIX/$PATH
      fi  
      ln -s $N_PREFIX/n/current/$PATH $N_PREFIX/$PATH
  done

  # install
  else
    local tarball="node-v$version.tar.gz"
    local url="http://nodejs.org/dist/$tarball"

    # >= 0.5.x
    local minor=$(echo $version | cut -d '.' -f 2)
    test $minor -ge "5" && url="http://nodejs.org/dist/v$version/$tarball"

    install_tarball $version $url $config
  fi
}

I haven't tested this, but if it seems reasonable (and any typos need corrected) I can submit a patch

@GoChime
GoChime commented Mar 7, 2012

Just experienced the same problem w/ 0.6.9.

@jprichardson

This error burns me every time I install a new Node version. I then forget about it and Google it and wind up back here... hahaha. TJ, do you have this issue?

@fgnass
fgnass commented Apr 26, 2012

Under Linux the trailing dot in line 146 prevents the wafadmin dir from being copied. Simply removing the dot fixes the problem but I'm not sure how cp behaves on other platforms.

@visionmedia What's the intention of that 3rd argument?

@sreuter
Contributor
sreuter commented Jun 9, 2012

@fgnass good catch!

@visionmedia what about that dot? :-)

@tj tj closed this in deefa0d Jun 14, 2012
@mattrobenolt
Contributor

This was reintroduced with 0d5e1ef

@j-hannes j-hannes referenced this issue Nov 2, 2012
Closed

Update bin/n #88

@stephenmelrose

+1 on getting this fixed. Very annoying!

@sreuter
Contributor
sreuter commented Dec 12, 2012

+1

Fix by @J-hannes works, it's the same as I did before this was reintroduced by 0d5e1ef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment