3

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?

SivanBH
  • 392
  • 3
  • 13
  • Why should Django be in dist-packages? By definition, that's for things that are installed by the distribution's package manager. Anything installed by `pip` goes in site-packages. – Daniel Roseman Jun 22 '15 at 15:13
  • I know, which is why I'm so baffled by this. – SivanBH Jun 24 '15 at 07:43
  • I came across [this question](http://stackoverflow.com/questions/9387928/whats-the-difference-between-dist-packages-and-site-packages) which could explain why pip installs packages into dist-packages. – SivanBH Jun 28 '15 at 11:33

1 Answers1

7

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

Brian Tingle
  • 981
  • 11
  • 23