Django installed in dist-packages

1.3k views Asked by At

I am working on an Amazon Linux AMI (version 2013.09). My goal, among other things, is to have Django up and running. So here's what I do:

  1. Install pip using yum (it installs pip 7.0.3 in Python2.7/dist-packages)
  2. Install virtualenv using pip
  3. Create a virtualenv (with --no-site-packages)
  4. Install Django using pip inside the virtualenv (this installs Django in the virtenv's Python directory, inside dist-packages)

This seems fine, until I try to use manage.py. The following line:

python manage.py collectstatic --noinput -c -l > /dev/null

Invokes the following error:

OSError: [Errno 2] No such file or directory: '...my-env/lib/python2.7/site-packages/django/contrib/admin/static'

Which is true, because the entire Django infrastructure is in dist-packages, not site-packages. What is the correct way of fixing this dependency?

Thanks!

UPDATE 28.06.15 The reason Django attempts to access site-packages is the 'STATIC_ROOT' definition in its settings.py file. Thing is, I installed Django in the exact same way, using the same settings, a couple of years ago, and it worked perfectly. So what's changed? Why has pip suddenly moved to dist-packages?

1

There are 1 answers

0
Brian Tingle On

sometimes PYTHON_INSTALL_LAYOUT="amzn" gets set in a shell and then stuff annoyingly goes into dist-packages.

To disable this annoyance, unset PYTHON_INSTALL_LAYOUT