2

私のサーバーには、2.4 と 2.7 の 2 つの Python バージョンがあります。RHEL 5.8 を実行しています。

サーバーには既に pip と easy_install がインストールされています。

easy_install または pip を使用して ipython をインストールしようとすると、おそらく python 2.4 ではサポートされていないエラーが表示されます。

両方の最新バージョンを使用したいので、pip と easy_install の両方に python 2.7 を使用したいと思います。

pip と easy_install で python 2.7 を使用するにはどうすればよいですか。Python 2.4 はシステムによってデフォルトでインストールされており、それを維持したいと考えています。

Python 2.7 は別の場所にインストールされます。

以下は、easy_install と pip の両方のトレースバックです。どちらも同じエラーになります。どんな種類の助けも大歓迎です。

PIP

ronak@ronak fun $ sudo pip install ipython
Downloading/unpacking ipython
  Downloading ipython-0.13.zip (6.4Mb): 6.4Mb downloaded
  Running setup.py egg_info for package ipython
    Traceback (most recent call last):
      File "<string>", line 14, in ?
      File "/usr/local/home/ronak/fun/build/ipython/setup.py", line 23
        from __future__ import print_function
    SyntaxError: future feature print_function is not defined
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
  File "<string>", line 14, in ?
  File "/usr/local/home/ronak/fun/build/ipython/setup.py", line 23
    from __future__ import print_function
SyntaxError: future feature print_function is not defined
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/ronak/.pip/pip.log

EASY_INSTALL:

ronak@ronak $ sudo easy_install ipython
Searching for ipython
Reading http://pypi.python.org/simple/ipython/
Reading http://ipython.scipy.org
Reading http://ipython.scipy.org/dist
Reading http://ipython.scipy.org/dist/0.8.4
Reading http://ipython.scipy.org/dist/0.9.1
Reading http://ipython.org
Reading http://archive.ipython.org/release/0.12.1
Reading https://github.com/ipython/ipython/downloads
Reading http://ipython.scipy.org/dist/old/0.9
Reading http://ipython.scipy.org/dist/0.10
Reading http://archive.ipython.org/release/0.11/
Reading http://archive.ipython.org/release/0.12
Best match: ipython 0.13
Downloading https://github.com/downloads/ipython/ipython/ipython-0.13.zip
Processing ipython-0.13.zip
Running ipython-0.13/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vgPLN2/ipython-0.13/egg-dist-tmp-GHUgsq
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1712, in main
    with_ei_usage(lambda:
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
    return f()
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1716, 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-0.6c11-py2.4.egg/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-0.6c11-py2.4.egg/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-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 476, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/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-0.6c11-py2.4.egg/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-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 919, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 61, in run_setup
    DirectorySandbox(setup_dir).run(
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 105, in run
    return func()
  File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 64, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 23
    from __future__ import print_function
SyntaxError: future feature print_function is not defined
4

4 に答える 4

2

1つの方法は次のとおりです。

  1. テキスト エディターで pip/easy_install を開きます

  2. 一番上の行を確認してください。

    #! /usr/bin/python

  3. #!path/to/python2.7 に変更します

于 2012-09-14T19:30:11.503 に答える
1

この SO questionを確認する必要があります。

仮想環境の使用を検討し、パッケージが使用する Python のバージョンを管理するvirtualenvこともできます。virtualenvwrapper

于 2012-09-15T13:57:47.810 に答える
0

sudo /location/to/python2.7 /path/to/pip install ipython

最近のバージョンの pip を使用している場合は、次のことも試してください。sudo pip-2.7 install ipython

于 2012-09-14T19:40:00.507 に答える
0

.dmg をダウンロードして iPython、SciPy、MatPlotLib などを簡単にインストールしたい場合は、ここで試してみてください。

http://www.enthought.com/products/epd_free.php

または、アカデミック メール アドレスをお持ちの場合:

http://www.enthought.com/products/edudownload.php

于 2012-09-14T19:34:43.527 に答える