0

当我尝试simplejson使用 easy_install 为 python 安装时,出现以下错误。

Searching for simplejson
Reading http://cheeseshop.python.org/pypi/simplejson/
Reading http://github.com/simplejson/simplejson
Reading http://cheeseshop.python.org/pypi/simplejson/3.3.0
Best match: simplejson 3.3.0
Downloading https://pypi.python.org/packages/source/s/simplejson/simplejson-3.3.0.tar.gz
Processing simplejson-3.3.0.tar.gz
Running simplejson-3.3.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-myQdjt/simplejson-3.3.0/egg-dist-tmp-fSRixt
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1670, in main
    with_ei_usage(lambda:
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1659, in with_ei_usage
    return f()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1674, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib64/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib64/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 211, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 471, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 655, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 930, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 919, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 26, in run_setup
    DirectorySandbox(setup_dir).run(
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 63, in run
    return func()
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 29, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 14
    with open('README.rst', 'r') as f:
        ^
SyntaxError: invalid syntax

输出为cat /proc/version

Linux version 2.6.18-164.el5 (mockbuild@x86-003.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue Aug 18 15:51:48 EDT 2009

关于可能是什么问题的任何评论。我想我做了很标准的安装。

4

2 回答 2

1

您的 Python 版本 (2.4) 对于最新的 simplejson 版本来说太旧了,因为它使用了 Python 2.4 中不可用的“with”语句。如果无法升级,请升级您的 Python 版本或尝试旧版本的 simplejson 或切换到与 Python 2.4 兼容的 json 模块。

于 2013-09-20T05:32:59.627 回答
0

尝试这个 :

get http://pypi.python.org/packages/source/s/simplejson/simplejson-2.0.9.tar.gz#md5=af5e67a39ca3408563411d357e6d5e47
tar xzvf simplejson-2.0.9.tar.gz
cd simplejson-2.0.9
sudo python setup.py install
于 2013-09-20T05:57:38.467 回答