I would need to see the full traceback along with the error message.

Also, if in the same directory you run the 'python' interpreter and go:

    import mysite.wsgi

what happens?

And, what do you have BASE_DIR set to in production.py?

Graham

> On 1 Jul 2017, at 7:03 PM, Anupam Jain <[email protected]> wrote:
> 
> (using mysite instead of projectname on this thread now, to be consistent 
> with the docs)
> 
> I think I have read all the relevant parts of the doc 
> <http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html> now 
> and followed it accurately but still getting the following error:
> 
> ImportError: No module named 'wsgi'
> 
> 
> Directory Structure:
> 
> mysite
>      - myapp
>          - views.py
>          - other files
>      - mysite 
>           - wsgi.py
>           - __init__.py
>           settings
>                  - __init__.py
>                  - base.py
>                  - production.py
>                  - development.py 
> 
> 
> Running the following command from: home/username/mysite/
> 
> mod_wsgi-express start-server wsgi.py --application-type module mysite.wsgi 
> --log-to-terminal
> 
> wsgi.py:
> 
> import os
> # import sys
> from django.core.wsgi import get_wsgi_application
> 
> # sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 
> "../../")))
> # sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 
> "../")))
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings.production")
> application = get_wsgi_application()
> 
> On Saturday, July 1, 2017 at 1:24:33 PM UTC+5:30, Graham Dumpleton wrote:
> 
>> On 1 Jul 2017, at 5:52 PM, Anupam Jain <[email protected] <>> wrote:
>> 
>> Answers inline, thanks
>> 
>> On Saturday, July 1, 2017 at 1:02:07 PM UTC+5:30, Graham Dumpleton wrote:
>> 
>>> On 1 Jul 2017, at 4:17 PM, Anupam Jain <[email protected] <>> wrote:
>>> 
>>> First of all - thanks for mod_wsgi express!
>>> 
>>> This <http://blog.dscpl.com.au/2015/04/introducing-modwsgi-express.html> 
>>> post says "As to the configuration of Apache, there actually wasn't any."
>>> 
>>> Is it ok to assume that I dont need to do any configuration on Apache at 
>>> all (as in nothing in conf-enabled/available and sites-enabled/available)? 
>>> (That sounds to be too good to be true so thought to check)
>> 
>> Do not touch any system Apache configuration files under /etc/apache2, 
>> /etc/httpd or whatever directory it is that your operating systems puts the 
>> Apache configuration. When you use mod_wsgi-express it completely ignores 
>> them, does not modify them, nor use them in any way.
>> 
>> Thats great to know 
>> 
>>> 
>>> I have setup everything for mod_wsgi express and getting the error 
>>> "ImportError: No module named '(projectname)'"
>> 
>> What command did you run and what arguments to mod_wsgi-express?
>> 
>> I used: mod_wsgi-express start-server wsgi.py 
>> 
>> If you get an error with that exact message, then it indicates you copied 
>> some template for something from somewhere where you were expected to 
>> replace '(projectname)' with a different value for your project. Did you do 
>> that? Or is this not actually the error message you go.
>>  
>> Thats not the exact message. I meant that its searching for the high level 
>> directory with the Django project name (directory structure below)
>> 
>> When you run mod_wsgi-express the directory you run mod_wsgi-express in 
>> should be added to the Python module search path, so as long as any modules 
>> can be imported from that location you should be good. If that shouldn't be 
>> the base directory for imports of your projects, you can use 
>> --working-directory option to override it, or use the --python-path option 
>> to specify additional directories to search for modules.
>> 
>> So what is the directory layout for your project, which directory are you 
>> running mod_wsgi-express from and with what arguments.
>> 
>> directory is something like this
>> 
>> projectname
>>      - appname
>>          - views.py
>>          - other files
>>      - projectname 
>>           - wsgi.py
>> 
>> running mod_wsgi-express from  /home/username/projectname/projectname
> 
> Wrong directory to run it from, plus you need extra arguments.
> 
> Read those other blogs posts I have linked to about using it with Django.
> 
> Once you have tried what is talked about in those, if still have issues let 
> me know.
> 
> Graham
> 
>> 
>>> This is not the one caused by circular imports but something to do with 
>>> setting the path somewhere I think (as I learnt from some SO posts) but not 
>>> entirely clear about it
>>> 
>>> I did setup a django.conf in Apache's conf-enabled, so I am suspecting that 
>>> may be conflicting with something.
>> 
>> It shouldn't as it will be ignored.
>> 
>> If you are using Django, you should perhaps look at:
>> 
>>     http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html 
>> <http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html>
>>     
>> http://blog.dscpl.com.au/2015/04/integrating-modwsgi-express-as-django.html 
>> <http://blog.dscpl.com.au/2015/04/integrating-modwsgi-express-as-django.html>
>> 
>> Also worthwhile reading:
>> 
>>     
>> http://blog.dscpl.com.au/2015/05/using-modwsgi-express-as-development.html 
>> <http://blog.dscpl.com.au/2015/05/using-modwsgi-express-as-development.html>
>> 
>> Note that if you have inherited an old Django code base which hasn't been 
>> updated correctly so the settings module includes settings defined in newer 
>> Django versions, and you have restructured your application code so the 
>> settings module is now at a different directory level, and you are using the 
>> method of integrating mod_wsgi-express into Django itself, you may also have 
>> issues with the settings module not being found when being imported.
>> 
>> So also indicate what version of Django your project code was originally 
>> created using.
>> 
>> The project was created on Django 1.10.2 and I am now moving it from dev to 
>> prod (GCP, Debian). Installed the same Django version on prod as well. I'll 
>> read the above Django posts as well but yes, I did create a settings 
>> directory under projectname/projectname which includes different versions of 
>> settings for dev and prod. I have set the environment variable for settings 
>> in the virtualenv's activate script. Also, os.environ.setdefault() is 
>> changed accordingly in wsgi.py
>> 
>> Graham
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>.
>> To post to this group, send email to mod...@ <>googlegroups.com 
>> <http://googlegroups.com/>.
>> Visit this group at https://groups.google.com/group/modwsgi 
>> <https://groups.google.com/group/modwsgi>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to