2013-03-23 109 views
2

我不想在CentOS 5.9上安裝'twisted'模塊。它有默認的python 2.4,並且由於其他程序的依賴關係,我無法刪除python 2.4。 我已經通過yum install python27安裝了Python 2.7,並通過yum install python-setuptools安裝了簡易安裝。現在,當我嘗試安裝「扭曲」與easy_install twisted我得到這個錯誤:確定易於安裝的python版本

< ... truncated ... > 
Running Twisted-12.3.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-YeUGBS/Twisted-12.3.0/egg-dist-tmp-NhwZo- 
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/lib/python2.4/distutils/core.py", line 149, in setup 
    dist.run_commands() 
    File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands 
    self.run_command(cmd) 
    File "/usr/lib/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 64, in ? 
    File "setup.py", line 46, in main 
    File "./twisted/__init__.py", line 47 
    class Dummy(object): 
     ^
SyntaxError: invalid syntax 

正如你看到的,簡易安裝使用Python 2.4,而不是2.7蟒的。它如何強制它使用python 2.7?

回答

3

您可以通過鍵入來手動使用您想要的Python版本,例如Python2.7 <script>。嘗試執行python2.7 -m easy_install twisted

如果由於某種原因easy_install未安裝Python 2.7您可以下載並手動安裝它here

+1

我想你需要在easy_install之前有一個'-m'。 – FatalError 2013-03-23 19:30:36

+0

啊,是的。 – eandersson 2013-03-23 19:30:56

+0

這很好。謝謝 – SuB 2013-03-23 19:35:45