2

尝试在我的 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

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

4

3 回答 3

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]
于 2013-05-11T15:11:00.300 回答
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);

现在安装库

$ python setup.py build
$ python setup.py test
$ python setup.py install 
于 2014-05-27T13:00:50.993 回答
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

这适用于我的使用如下 spidermonkey 模块的 python 代码。希望这可以帮助。

rt = spidermonkey.Runtime()
cx = rt.new_context()
cx.execute(js)
cx.execute("...")
于 2014-05-07T15:07:05.197 回答