WebFaction
Community site: login faq

I'm having a problem with my virtual env pulling from my account's global python packages.

I tracked down this note and followed the tip to create a sitecustomize.py file within the virtual environments python folder. But I've not setup virtualenvwrapper, so my paths are slightly different.

And, if I start the virtualenv for the project and check which django version I'm running it's all good:

django-admin.py --version
1.11.7

However the when I actually try and run the site I get errors showing that it's using the global django, which is a 1.8.xx

[Sun Nov 12 23:53:09.748394 2017] [wsgi:error]    File "/home/myaccount/lib/python2.7/django/core/handlers/base.py", line 264, in handle_uncaught_exception
[Sun Nov 12 23:53:09.748412 2017] [wsgi:error]      if resolver.urlconf_module is None:
[Sun Nov 12 23:53:09.748425 2017] [wsgi:error]    File "/home/myaccount/lib/python2.7/django/core/urlresolvers.py", line 395, in urlconf_module
[Sun Nov 12 23:53:09.748464 2017] [wsgi:error]      self._urlconf_module = import_module(self.urlconf_name)
[Sun Nov 12 23:53:09.748479 2017] [wsgi:error]    File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Sun Nov 12 23:53:09.748497 2017] [wsgi:error]      __import__(name)
[Sun Nov 12 23:53:09.748509 2017] [wsgi:error]    File "/home/myaccount/webapps/myapp/myapp/myapp/urls.py", line 18, in <module>
[Sun Nov 12 23:53:09.748526 2017] [wsgi:error]      from directory.views import DefaultList, post_new, modify, ReviewList, taken
[Sun Nov 12 23:53:09.748539 2017] [wsgi:error]    File "/home/myaccount/webapps/myapp/myapp/directory/views.py", line 7, in <module>
[Sun Nov 12 23:53:09.748557 2017] [wsgi:error]      from django.contrib.auth.mixins import LoginRequiredMixin
[Sun Nov 12 23:53:09.748575 2017] [wsgi:error]  ImportError: No module named mixins

This particular project is a play/test project. The rest of the apps running on my account are still in django 1.8.x and now I don't want to mess with the global settings because its apparent I haven't successfully isolated my environments.

So, any pointers on how to track down which setting that's pulling in my global settings?

My apache and wsgi.py settings are copied, more or less, from here.

asked 13 Nov, 00:07

leehinde's gravatar image

leehinde
3519
accept rate: 0%

And this happens when you start your Django app after activating the virtualenv?

(13 Nov, 04:36) NickR ♦♦ NickR's gravatar image

Yes. That error comes when I first try to hit the page.

(13 Nov, 19:28) leehinde leehinde's gravatar image

  1. Remove the activate_this and site.addsitedir stuff from your wsgi.py.
  2. Remove the WSGIPythonPath line from httpd.conf.
  3. Remove /home/myaccount/lib/python2.7 from the python-path parameter of your WSGIDaemonProcess directive in httpd.conf
  4. Add a WSGIPythonHome directive to http.conf, just before the WSGIDaemonProcess directive, pointing to the top directory of your virtualenv, eg:

    WSGIPythonHome /home/myaccount/.virtualenvs/whatever

Restart your Apache after you've made the above changes, and you should then be up and running.

permanent link

answered 13 Nov, 19:41

seanf's gravatar image

seanf ♦♦
11.9k21333
accept rate: 37%

edited 13 Nov, 19:42

I will try that. Thanks!

(13 Nov, 19:42) leehinde leehinde's gravatar image

That was exactly it. I'll now spend some time to see if I can understand and not just monkey-type.

(13 Nov, 22:19) leehinde leehinde's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×891
×52

question asked: 13 Nov, 00:07

question was seen: 36 times

last updated: 13 Nov, 22:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2017 PARAGON INTERNET GROUP LIMITED
WEBFACTION IS A SERVICE OF PARAGON INTERNET GROUP LIMITED
REGISTERED IN ENGLAND AND WALES 7573953 - VAT REGISTRATION NUMBER 182147021
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM