Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to setup flask with uwsgi. This is my directory structure:

/srv/http/www/myapp
|
+-- env -> virtualenv
|
+-- mpd -> the project directory
  |
  +-- main.py -> main application

And I'm using this command:

uwsgi -s 127.0.0.1:3002 --chdir webmpd --uid 33 --gid 33 --plugin python -H env --module main --callable app

And I get this error:

*** Starting uWSGI 1.9.19 (32bit) on [Sat Nov 30 22:37:33 2013] ***
compiled with version: 4.7.2 on 13 November 2013 15:40:36
os: Linux-3.10.19-3-ARCH #1 PREEMPT Thu Nov 21 20:33:10 CST 2013
nodename: raspy
machine: armv6l
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /srv/http/www/mpd
detected binary path: /usr/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 33
setuid() to 33
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 1321
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3002 fd 3
Python version: 3.3.3 (default, Nov 29 2013, 11:19:14)  [GCC 4.7.2]
Set PythonHome to env
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted

I have looked around a lot and this problem seems to be stemming from mismatched python version between uwsgi and the system, but in my case, both are running python 3.3. I don't know what else could be wrong.

Any help is appreciated.

share|improve this question
    
Check your virtualenv (try removing it from the uWSGI options to see if the errors disappears) –  roberto Dec 1 '13 at 4:49

1 Answer 1

I don't know if you solved your problem since (I hope for you), but the problem comes from that your python environment is not correctly found.

So you should use an absolute path for your python environment that you setted at "env"

The short way : use this command line

uwsgi -s 127.0.0.1:3002 --chdir webmpd --uid 33 --gid 33 --plugin python -H /srv/http/www/myapp/env --module main --callable app

Please be sure, that the user running uwsgi is authorized to access to this path.

I hope it helps !

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.