0

I've inherited a project on a hosted server and I'm trying to install and import numpy and nltk into the project. The OS is centOs 5.10 and the web app uses web.py. There are two version of python installed on the box both python 2.4 and python 3.3. The default is pointing to version 2.4, "python -V" = python 2.4.3. Eventually I will upgrade and use python 3.3, move toward Django, etc but for the time being I'm stuck with this setup. I've been researching a while on how to do this. From my research I've read about using pip to install numpy and then nltk. In the python2.4 directory I was able to use easy_install to install pip-1.4.1-py2.4.egg. When I try to use pip-2.4 to install anything I get a syntax error in the pip file. See below...

$pip-2.4 numpy

File "/home/slrp/bin/pip-2.4", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/slrp/lib/python2.4/pip-1.4.1-py2.4.egg/pip/__init__.py", line 10, in ?
from pip.util import get_installed_distributions, get_prog
File "/home/slrp/lib/python2.4/pip-1.4.1-py2.4.egg/pip/util.py", line 17, in ?
from pip.vendor.distlib import version
File "/home/slrp/lib/python2.4/pip-1.4.1-py2.4.egg/pip/vendor/__init__.py", line 8
from __future__ import absolute_import
SyntaxError: from __future__ imports must occur at the beginning of the file

Doing some research it's seems this error comes from the fact that I have multiple python installs. This lead me to install virtualenv-1.10.1-py2.4.egg in the python2.4. But when I try to run virtualenv I get the following error.

ERROR: this script requires Python 2.6 or greater.

I've also tried to install numpy using python2.4's easy install but that errors out as well.

  $easy_install-2.4 numpy

  File "/usr/bin/easy_install-2.4", 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 16
  from __future__ import division, print_function
  SyntaxError: future feature print_function is not defined

Again I don't want to upgrade or change the version of python. In the python3.3 directory I was able to successfully run virtualenv. I was hoping this would correct any dependency issue that I might be having because of the multiple installs, but it hasn't. My plan right now is to try and get virtualenv to successfully run for the python2.4 version. My hope is that if I can set up virtual environments for both versions of python it will resolve the problem. But as you can see I can't get virtualenv in python2.4 to successfully run. Below is some more information about what is in each python directory.

[user@server python3.3]$ ls
easy-install.pth  nltk-2.0.4-py3.3.egg  numpy-1.8.0-py3.3.egg-info  PyYAML-3.10-py3.3-linux-i686.egg
ENV               numpy                 pip-1.4.1-py3.3.egg         virtualenv-1.10.1-py3.3.egg


[user@server python2.4]$ ls
easy-install.pth  git_remote_helpers  MySQL_python-1.2.3c1-py2.4-linux-i686.egg  pip-1.4.1-py2.4.egg  virtualenv-1.10.1-py2.4.egg  web

There is a lot of stuff out there for this and I've been researching for a while. Any help is greatly appreciated! Thanks!

1 Answer 1

1

You have multiple issues, first of all python 2.4 not being supported anymore by recent (versions of) libraries.

You need to get a hold of virtualenv 1.7.2 (since 1.8 dropped support for 2.4)

I am not sure if you can make the jump from 2.4 to 3.3 without problems, the actual code you work with (not the 3rd party stuff) will need adapting. I would at least consider to make the intermediate step of using Python 2.7. It is compatible with 2.4 and has many of the 3.3 features as well as a more compatible (with 3.3) standard library.

The package six might be helpful in addition to the 2to3 tool that comes with python.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .