You are not logged in.

#1 2012-04-22 13:42:35

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

[Solved] python nginx and uwsgi

Hi, I am attempting to get nginx and uwsgi running on my local box, I followed any number of tutorials and this one had the most complete information.
http://gekicstart.ca/tech-posts/nginxuwsgidjango-stack/

It is written for Debian\Ubuntu so I had to transpose a bit. I got through most of it and I got to the section on creating the daemon for uwsgi that loads a specific project. It creates a /etc/init/projectX.conf file that it loads the uwsgi specific information from. I didn't know enough to create a daemon in arch so I opted for running the command by cli.

/usr/bin/uwsgi socket /root/Workspace/Eclipse/sockets/projectX.sock --chmod-socket --module wsgi_app --pythonpath /root/Workspace/Eclipse/projectX/uwsgi -p 1

I also extended the relative paths to absolute from the example code, so far so good. but when it loads the below file.

when I run this it craps on the django import


 #!/usr/bin/python2.7
  2 import sys
  3 import os
  4 import django.core.handlers.wsgi
  5 sys.path.append("/Eclipse/")
  6 os.environ['DJANGO_SETTINGS_MODULE'] = 'projectX.settings'
  7 application = django.core.handlers.wsgi.WSGIHandler()

It can't find django, I tested by reducing the statement

import django.core.handlers.wsgi

section by section, in other words I tested 'import django.core.handlers', 'import django.core' etc. each time it couldn't find the reference, I know that django is loaded in python2.7/site-packages.

Further I also opened up a python2.7 prompt and used the same import statement successfully. I tried changing the declaration for the python script to

#!/usr/bin/python
#!/usr/bin/python2
#!/usr/bin/python2.7

None has solved the problem. Does anyone have an idea why it can't see django? The python prompt sees it no problem.

thanks in advance for your help.

--jerry

Last edited by jk121960 (2012-04-24 11:29:21)


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#2 2012-04-23 21:45:23

aspidites
Member
Registered: 2011-03-11
Posts: 30

Re: [Solved] python nginx and uwsgi

And what happens if you do the following before importing django (when running the script, not from within the interpreter:

print(sys.path)

coder formally known as EnvoyRising

Offline

#3 2012-04-24 11:29:01

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: [Solved] python nginx and uwsgi

Hi, I finally figured it out and I meant to reply yesterday, but what I did was recompile with a python2.7 option, this solved the immediate problem. I am still dealing with some others but hopefully I will figure those out also.

thanks for your post and your help .


--jerry


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

Board footer

Powered by FluxBB