2

I am brand new to Python, and have been trying to get the Django framework installed on my server. I can't seem to find an answer or even a hint in the right direction anywhere online for this issue.

I have a VPS over at LiquidWeb and I am trying to install on that server. I've been following the Django installation guide over at: https://docs.djangoproject.com/en/1.4/topics/install/#installing-official-release

I am trying to install the stable release, not the development version, and have tried installing manually and via PIP - both are giving me the same error, listed below:

root@host [/]# sudo pip install Django

Downloading/unpacking Django

Downloading Django-1.4.1.tar.gz (7.7Mb): 7.7Mb downloaded

Running setup.py egg_info for package Django

Traceback (most recent call last):

  File "<string>", line 14, in ?

  File "/build/Django/setup.py", line 69, in ?

    version = __import__('django').get_version()

  File "django/__init__.py", line 15

    parts = 2 if version[2] == 0 else 3

               ^
SyntaxError: invalid syntax

Command python setup.py egg_info failed with error code 1 in /build/Django Storing complete log in /root/.pip/pip.log

I am using Python 2.4.3 and trying to install Django 1.4.1.

Any help would be greatly appreciated, thanks in advance!

2 Answers 2

8

Wait, you're using Python 2.4?! Django 1.4 dropped support for 2.4. You'll have to upgrade Python to get it to work. If you're upgrading, you may as well use latest Python 2 version (2.7).

The exact cause of the error is that the setup script uses the ternary conditional operator (true_expr if cond else false_expr), which I think was introduced in Python 2.5. While you could work around it by editing the script, similar things will probably be all over the Django codebase, so you would have to backport the entire framework.

Sign up to request clarification or add additional context in comments.

9 Comments

Specifically, he needs version 2.6.5 or higher. I am going to guess 2.4 is from CentOS or RHEL 5. He needs 2.6 from EPEL.
@jordanm: The release notes say "Python 2.5 is now the minimum required Python version.".
That's different than what the installation guide says: docs.djangoproject.com/en/dev/intro/install
@Mechanical: 2.5 is not in the repos.
@Piet: They no longer receive upstream updates, but RH will keep patching vulnerabilities until RHEL 5 is fully out of service.
|
3

Let me guess~

Perhaps the error is not about your Django or python's version.

If you got the right version.and this still occurs.

The problem may caused by your mod_wsgi.

run this:

ldd /usr/lib/httpd/modules/mod_wsgi.so

if return this 'libpython2.4.so.1.0 => /usr/lib/libpython2.4.so.1.0 (0x00b32000)'

linux-gate.so.1 =>  (0x00da0000)
        libpython2.4.so.1.0 => /usr/lib/libpython2.4.so.1.0 (0x00b32000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00d7b000)
        libdl.so.2 => /lib/libdl.so.2 (0x007cf000)
        libutil.so.1 => /lib/libutil.so.1 (0x00f6f000)
        libm.so.6 => /lib/libm.so.6 (0x0086e000)
        libc.so.6 => /lib/libc.so.6 (0x00150000)
        /lib/ld-linux.so.2 (0x00133000)

You need recompile your mod_wsgi.so,with the param '--with-python=/usr/local/bin/python2.7'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.