Discussion:
django on rhel5 with both python2.4 and python2.7 confusion
David Malcolm
2014-05-07 09:08:40 UTC
Permalink
I have been tasked with finishing a build for production that was
interrupted due to another staff member leaving at short notice. It's
RedHat Enterprise Linux 5 and there are two versions of python on the box.
If I type python I get version 2.7. However if I try and use
django-admin.py I find that it is trying to use python version 2.4. How do
I specify to Django that I want to use python 2.7? I've seen multiple
supposed answers on the net but nothing actually seems to answer my
specific question. I'm fairly experienced on linux but have never had to
setup django and python before. My Apache, php, phpMyAdmin setup is all
working properly (after I sorted out some other issues), but my second
question is how do I wire up python/django to apache (or httpd as rhel5
calls it). I've tried using mod_wsgi but have been told I must use
mod_python. Advice or pointers to relevant urls are much appreciated.
Thanks Dave, Melbourne
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/74af440c-b42d-4fcd-abfa-74da94958b73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Timothy W. Cook
2014-05-07 11:37:10 UTC
Permalink
A good place to start is with this thread:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/django-users/_0RTNcYyCSI/24QinBTEnX8J


Be sure to include CentOS in your searches for clues about this setup since
many people use CentOS instead of RHEL.

HTH,
Tim
Post by David Malcolm
I have been tasked with finishing a build for production that was
interrupted due to another staff member leaving at short notice. It's
RedHat Enterprise Linux 5 and there are two versions of python on the box.
If I type python I get version 2.7. However if I try and use
django-admin.py I find that it is trying to use python version 2.4. How do
I specify to Django that I want to use python 2.7? I've seen multiple
supposed answers on the net but nothing actually seems to answer my
specific question. I'm fairly experienced on linux but have never had to
setup django and python before. My Apache, php, phpMyAdmin setup is all
working properly (after I sorted out some other issues), but my second
question is how do I wire up python/django to apache (or httpd as rhel5
calls it). I've tried using mod_wsgi but have been told I must use
mod_python. Advice or pointers to relevant urls are much appreciated.
Thanks Dave, Melbourne
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/74af440c-b42d-4fcd-abfa-74da94958b73%40googlegroups.com<https://groups.google.com/d/msgid/django-users/74af440c-b42d-4fcd-abfa-74da94958b73%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3UYTe0r6gqiCQj3%3DcQh6EqMrRzQDk5-R-9cxd9CCQPR0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
David Malcolm
2014-05-12 10:50:42 UTC
Permalink
Hi Timothy

thanks for your suggestions. I'm still on the path. I'll put more details in my reply to WongoBongo below.

cheers
Dave
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f10d728f-b690-4681-8807-0c66d7ddd8b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Timothy W. Cook
2014-05-12 11:34:48 UTC
Permalink
I can't imagine virtualenv being a vulnerability risk. AFAIK; All it does
is create a set of scripts to isolate the executing Python environment.
http://virtualenv.readthedocs.org/en/latest/virtualenv.html

In fact, I would almost say that it improves your ability to know EXACTLY
what is in your environment irregardless of the rest of the machine.

Frankly, I do not create any Python code outside of a specified virtualenv.
Web apps or any other scripts or apps.
Post by David Malcolm
Hi Timothy
thanks for your suggestions. I'm still on the path. I'll put more details
in my reply to WongoBongo below.
cheers
Dave
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/f10d728f-b690-4681-8807-0c66d7ddd8b9%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.
--
============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3Ui-QV2TRKq3PgOxy4pPBgpRzDS_0S5ZK%2BwzpmgJEHjMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Kelvin Wong
2014-05-08 05:09:34 UTC
Permalink
Question one...

The gist is:

1. Set up Virtualenv and Virtualenvwrapper (lots of howtos on the web for
this - find one written in the last year)
2. Set correct environment keys to point to the right Python (similar to
the following, you paths may be different)

# ~/.bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/.local/bin/virtualenv-2.7
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
source $HOME/.local/bin/virtualenvwrapper.sh

3. Make a virtualenv: like this $ mkvirtualenv myappenv
4. Install Django into the virtualenv (you should have been dumped into it
after you made it): (myappenv) $ pip install Django
5. Check which django-admin.py you are using

$ which django-admin.py
/home/myuser/.virtualenvs/myappenv/bin/django-admin.py

Hint: Webfaction uses CentOS with many different types of Pythons.
Searching their support website may be helpful.

---

Question two: Use mod_wsgi rather than mod_python. See warning at the top
of the Dj1.4 docs

https://docs.djangoproject.com/en/1.4/howto/deployment/modpython/

Setting up a Django app is more complex than setting up a PHP app (one
persons opinion). The benefit is that at the end of the ordeal you will be
running Python and not PHP (one persons opinion).

:)

K
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a5356de2-3b61-45d6-a9de-8c76472d2a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
David Malcolm
2014-05-12 11:09:38 UTC
Permalink
thanks for your reply WB.

I was hoping to avoid virtualenv. My webapp is a frontend to a vulnerability scanner in a large corporation.
They are very picky about what I can use and what I can't. Is virtualenv suitable for such a production system?
They insist that I cannot use mod_wsgi (it annoys me intensely, but hey that's life) and HAVE to use mod_python.
Is there any other way to get this working without virtualenv?

I also have no choice about OS. rhel6 is undergoing an approval process as an SOE but it won't happen any time soon :(

I am so close to getting this working now but it does indeed look like django (httpd) is using python2.4.
Note that "which python" gives me 2.7 - what is causing django to use python & mod_python 2.4? mod_python is installed for 2.7.

Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
log=debug)
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 461, in import_module
f, p, d = imp.find_module(parts[i], path)
ImportError: No module named django

thanks for your help.
cheers Dave
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/85c41d50-e41e-4c2f-9951-59c020038cd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tom Evans
2014-05-12 13:11:01 UTC
Permalink
Post by David Malcolm
thanks for your reply WB.
I was hoping to avoid virtualenv. My webapp is a frontend to a vulnerability scanner in a large corporation.
They are very picky about what I can use and what I can't. Is virtualenv suitable for such a production system?
If I ever come across a production system where a python app is not
installed in a virtualenv, I consider that a bug. virtualenv is the
basis of all of our python production systems (our dev systems too).
Post by David Malcolm
They insist that I cannot use mod_wsgi (it annoys me intensely, but hey that's life) and HAVE to use mod_python.
mod_python is old, insecure, unmaintained, unmanaged - and most
importantly - not supported for django.
Post by David Malcolm
Is there any other way to get this working without virtualenv?
Find the right person to talk to your in your org, tell them that
mod_python is dangerous, and that virtualenv is the industry standard
way of deploying a python application, and that wsgi is the industry
standard way of connecting a python web application to a web server.

Cheers

Tom
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1KKVS_ULyJi%3DEOG8n10yn5AO775U3-5qF-sq6zavADgeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Kelvin Wong
2014-05-17 06:21:54 UTC
Permalink
I haven't used mod_python in such a long time that I don't recall the
configuration details. Off the top of my head, you might want to check how
to add the Python 2.7 site-packages folder to the path that mod_python
searches for python modules like Django.

Also, check this out on SO.

http://stackoverflow.com/questions/2147695/how-do-i-change-which-version-of-python-mod-python-uses

K
Post by David Malcolm
thanks for your reply WB.
I was hoping to avoid virtualenv. My webapp is a frontend to a
vulnerability scanner in a large corporation.
They are very picky about what I can use and what I can't. Is virtualenv
suitable for such a production system?
They insist that I cannot use mod_wsgi (it annoys me intensely, but hey
that's life) and HAVE to use mod_python.
Is there any other way to get this working without virtualenv?
I also have no choice about OS. rhel6 is undergoing an approval process as
an SOE but it won't happen any time soon :(
I am so close to getting this working now but it does indeed look like
django (httpd) is using python2.4.
Note that "which python" gives me 2.7 - what is causing django to use
python & mod_python 2.4? mod_python is installed for 2.7.
Mod_python error: "PythonHandler django.core.handlers.modpython"
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line
287, in HandlerDispatch
log=debug)
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line
461, in import_module
f, p, d = imp.find_module(parts[i], path)
ImportError: No module named django
thanks for your help.
cheers Dave
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/649d98d0-9a44-40a1-8a89-4da387487833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...