I noticed something odd today:
root@jenk-heat-669-node1_horizon_container-9c60dd1b:~# source /openstack/venvs/horizon-master/bin/activate
(horizon-master)root@jenk-heat-669-node1_horizon_container-9c60dd1b:~# horizon-manage.py clearsessions
Traceback (most recent call last):
File "/openstack/venvs/horizon-master/bin/horizon-manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/core/management/__init__.py", line 325, in execute
django.setup()
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/contrib/auth/models.py", line 41, in <module>
class Permission(models.Model):
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/models/base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/models/options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/utils.py", line 240, in __getitem__
backend = load_backend(db['ENGINE'])
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/openstack/venvs/horizon-master/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 27, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
(horizon-master)root@jenk-heat-669-node1_horizon_container-9c60dd1b:~#
If you run this command outside of the venv, it works fine:
(horizon-master)root@jenk-heat-669-node1_horizon_container-9c60dd1b:~# deactivate
root@jenk-heat-669-node1_horizon_container-9c60dd1b:~# /openstack/venvs/horizon-master/bin/horizon-manage.py clearsessions
root@jenk-heat-669-node1_horizon_container-9c60dd1b:~#
Is this behaviour correct? I would have thought I should be able to run horizon-manage.py inside the venv, and if that assumption is correct then it looks like we're not installing all the necessary packages in the venv. Further, and I guess more importantly, any time we run a venv command without being inside the venv we run the risk of including libraries outside of the venv. Should we be changing any cronjob etc. that does this to set the PYTHONPATH so we restrict this from happening?
Thoughts?
--Matt
can you output your `env`?