Description of problem: Created a scalable python application using quick start from https://github.com/openshift/django-example.git and instructions from comment https://openshift.redhat.com/community/comment/reply/8095/16195. Instructions work great with the regular application but fails in scalable env. It appears that /virt/bin/activate is not activating the env properly on slave gears. On primary gear - No error: [rangoscale-sannam.rhcloud.com ~]\> source $OPENSHIFT_GEAR_DIR/virtenv/bin/activate (virtenv)[rangoscale-sannam.rhcloud.com ~]\> export PYTHON_EGG_CACHE=$OPENSHIFT_GEAR_DIR/virtenv/lib/python-2.6 (virtenv)[rangoscale-sannam.rhcloud.com ~]\> python Python 2.6.6 (r266:84292, Aug 28 2012, 10:55:56) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django.core.management import execute_manager >>> On secondary gear - doing the same source, export, results in "no module error": [rangoscale-sannam.rhcloud.com ~]\> ssh e57c87a536eb41fdba69d8749dba81e5.80.47 [e57c87a536-sannam.rhcloud.com ~]\> source $OPENSHIFT_GEAR_DIR/virtenv/bin/activate (virtenv)[e57c87a536-sannam.rhcloud.com ~]\> export PYTHON_EGG_CACHE=$OPENSHIFT_GEAR_DIR/virtenv/lib/python-2.6 (virtenv)[e57c87a536-sannam.rhcloud.com ~]\> python Python 2.6.6 (r266:84292, Aug 28 2012, 10:55:56) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django.core.management import execute_manager Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named django.core.management Git push of the application also results in the no module error because syncdb command is getting executed on the secondary gear. Deploy hook getting executed: remote: + ssh e57c87a536eb41fdba69d8749dba81e5.80.47 deploy.sh remote: Running .openshift/action_hooks/deploy remote: Executing 'python /var/lib/stickshift/e57c87a536eb41fdba69d8749dba81e5/app-root/runtime/repo//wsgi/openshift/manage.py syncdb --noinput' remote: Traceback (most recent call last): remote: File "/var/lib/stickshift/e57c87a536eb41fdba69d8749dba81e5/app-root/runtime/repo/wsgi/openshift/manage.py", line 2, in <module> remote: from django.core.management import execute_manager remote: ImportError: No module named django.core.management remote: Executing 'python /var/lib/stickshift/e57c87a536eb41fdba69d8749dba81e5/app-root/runtime/repo//wsgi/openshift/manage.py collectstatic --noinput' remote: Traceback (most recent call last): remote: File "/var/lib/stickshift/e57c87a536eb41fdba69d8749dba81e5/app-root/runtime/repo/wsgi/openshift/manage.py", line 2, in <module> remote: from django.core.management import execute_manager remote: ImportError: No module named django.core.management Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. Follow instructions from https://openshift.redhat.com/community/comment/reply/8095/16195 2. Replace OPENSHIFT_APP_DIR with OPENSHIFT_GEAR_DIR in the instructions from the above link. 3. git push should result in no module error 4. login via ssh into primary gear and run source $OPENSHIFT_GEAR_DIR/virtenv/bin/activate export PYTHON_EGG_CACHE=$OPENSHIFT_GEAR_DIR/virtenv/lib/python-2.6 python at the prompt enter : from django.core.management import execute_manager 5. login via ssh into secondary gear and repeat steps from 4. Actual results: Expected results: Additional info:
Notes from Ramr: that might be a bug with virtenv/bin/activate (yeah might be because of the UUIDs of the gear -- different on the primary and slave gears and we just rsync it).
Fixed with pull request: https://github.com/openshift/crankcase/pull/582 waiting on merge
*** Bug 851007 has been marked as a duplicate of this bug. ***
Tested against devenv_2301 (ami-d817abb1). I still can see 'ImportError: No module named django.core.management' during deployment. Can you please verify steps to reproduce? The link to the forum post is outdated.
This works fine for me on the devenv launched yesterday. Here's the steps I used to verify: 1. Create python app: rhc app create -a applepie -t python-2.6 -s -d 2. Add django dependency cd applepie/ # edit setup.py and uncomment the Django dependency line sed -i "s/^\s*#\(\s*install_requires.*\)/\1/" setup.py git commit . -m 'django rides again' && git push 3. Once the deployment completes (push completes), ssh into the app ssh $uuid@$dns # ssh to haproxy gear haproxy-gear-sh> source python-2.6/virtenv/bin/activate haproxy-gear-sh (virtenv)> python -c "import django; print django" 4. Get ssh info for the other gears. haproxy-gear-sh> cat haproxy-1.4/conf/gear-registry.db 5. For each of the slave/serving gears -- ssh into those gears and run: haproxy-gear-sh> ssh to slave gear (found in step 4) slave-gear-sh> source python-2.6/virtenv/bin/activate slave-gear-sh (virtenv)> python -c "import django; print django" That should run on all the gears. You can also change the python command to be something like: python -c "import django.core.management; print django.core.management" If you want to look at the django core management bits.
verified with devenv_2307 python -c "import django; print django" <module 'django' from '/var/lib/openshift/7b44a04aa4714f7cb8371303076608f1/python-2.6/virtenv/lib/python2.6/site-packages/Django-1.4.1-py2.6.egg/django/__init__.pyc'>