Решите, какую версию Python использовать для pip и easy_install

У меня есть две версии Python на моем сервере, а именно 2.4 и 2.7. Это работает RHEL 5.8.

На моем сервере уже установлены pip и easy_install.

Когда я пытаюсь установить ipython с помощью easy_install или pip, он выдает ошибку, которая, вероятно, не поддерживается в python 2.4.

Я хочу использовать python 2.7 для pip и easy_install, так как я хотел бы использовать последнюю версию обоих.

Что мне нужно сделать, чтобы 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 ответа

Решение

Одним из способов будет:

  1. Откройте pip/easy_install в текстовом редакторе

  2. Проверьте верхнюю строку, это должно сказать

    #! / USR / бен / питон

  3. Измените его на #! Path/ на /python2.7

Вы должны проверить этот ТАК вопрос.

Вы также можете рассмотреть возможность использования виртуальной среды через virtualenv а также virtualenvwrapper чтобы определить, какую версию Python должны использовать ваши пакеты.

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

Если у вас есть последняя версия pip, вы также можете попробовать sudo pip-2.7 install ipython

Если вы хотите легко установить iPython, SciPy, MatPlotLib и т. Д., Загрузив.dmg, вы можете попробовать здесь:

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

Или, если у вас есть академический адрес электронной почты:

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

Другие вопросы по тегам