Mac OS - 无法安装python-spidermonkey,因为找不到nspr

时间:2013-04-27 00:32:48

标签: python macos nspr

尝试在我的Mac OS上使用pip安装python-spidermonkey,但没有这样做,因为它缺少nspr:

$ pip install python-spidermonkey
Downloading/unpacking python-spidermonkey
  Running setup.py egg_info for package python-spidermonkey
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 186, in <module>
        **platform_config()
      File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 143, in platform_config
        return nspr_config(config=config)
      File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 87, in nspr_config
        return pkg_config("nspr", config)
      File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 59, in pkg_config
        raise RuntimeError("No package configuration found for: %s" % pkg_name)
    RuntimeError: No package configuration found for: nspr
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/Users/shengjiemin/work/Ceilo-ENV/build/python-spidermonkey/setup.py", line 186, in <module>

    **platform_config()

  File "/Users/smin/rmonkey/setup.py", line 143, in platform_config

    return nspr_config(config=config)

  File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 87, in nspr_config

    return pkg_config("nspr", config)

  File "/Users/smin/ENV/build/python-spidermonkey/setup.py", line 59, in pkg_config

    raise RuntimeError("No package configuration found for: %s" % pkg_name)

RuntimeError: No package configuration found for: nspr

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /Users/smin/ENV/build/python-spidermonkey

然后我尝试安装nspr:

sudo port install nspr

但它没有任何区别,仍然是同样的错误。有什么想法吗?

3 个答案:

答案 0 :(得分:1)

最后,我通过跟随这里的主题来解决这个问题:

http://davisp.lighthouseapp.com/projects/26898/tickets/38-trouble-installing-on-mac-os-x-107

两个步骤:

1.将spidermonkey中Darwin-XXX文件夹中的文件移动到spider monkey / libjs以解决此错误。

cd /home/smin/virt-ENV/build/python-spidermonkey/spidermonkey
mv Darwin-i386/* libjs/

2.在文件中进行以下更改:libjs/jsutil

从:

typedef int js_static_assert_line##line[(condition) ? 1 : -1]

为:

typedef int js_static_assert_line##line[(condition) ? 1 : 0]

答案 1 :(得分:0)

我找到了一个解决方法(下面的第三行),用于在MacOS 10.9上安装。

$ brew install pkg-config
$ brew install nspr
$ cd /usr/local/lib/pkgconfig/  # IMPORTANT
$ ln -s nspr.pc ../../Cellar/nspr/4.10.8_1/lib/pkgconfig/nspr.pc

$ git clone git://github.com/davisp/python-spidermonkey.git
$ cd python-spidermonkey
$ cp spidermonkey/Linux-x86_64/* spidermonkey/libjs/
$ python setup.py build
$ python setup.py test  # test failed, but it's okay to ignore

$ sudo python setup.py install

这适用于我的python代码,使用下面的spidermonkey模块。希望这会有所帮助。

rt = spidermonkey.Runtime()
cx = rt.new_context()
cx.execute(js)
cx.execute("...")

答案 2 :(得分:0)

首先安装nspr并设置系统变量:

$ brew install pkg-config
$ brew install nspr
$ export ARCHFLAGS="-arch x86_64" 
$ export PKG_CONFIG_PATH=/path/to/pkgconfig ## e.g. /usr/local/lib/pkgconfig

现在获取最新版本的代码:

$ git clone git://github.com/davisp/python-spidermonkey.git

现在运行update js libs并删除tmp目录:

$ update-libjs.sh
$ rm -r /path/to/tmp/in/spidermonkey/dir ## e.g. ./tmp

文件libjs / jsutil.h替换第76行 来自

typedef int js_static_assert_line_##line[(condition) ? 1 : -1]

typedef int js_static_assert_line_##line[(condition) ? 1 : 0]

文件libjs / jsprf.c注释行644

//VARARGS_ASSIGN(nas[cn].ap, ap);

现在安装lib

$ python setup.py build
$ python setup.py test
$ python setup.py install