Here's the error:
Traceback (most recent call last):
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
mw_class = import_by_path(middleware_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 21, in import_by_path
module = import_module(module_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/middleware/doc.py", line 4, in <module>
warnings.warn(__doc__, PendingDeprecationWarning, stacklevel=2)
TypeError: expected string or buffer
TypeError: expected string or buffer
Tango is the user I created specifically for this project.
I'm using upstart so in /etc/init/tango-wsgi.conf looks like:
exec /var/apps/tango/envs/tango-env/bin/uwsgi \
--uid tango \
--home /var/apps/tango/envs/tango-env \
--pythonpath /var/apps/tango/tango/src \
--wsgi-file /var/apps/tango/tango/src/tango_cms/wsgi.py \
--socket /tmp/tango-uwsgi.sock \
--chmod-socket \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/apps/tango/logs/uwsgi.log
UPDATE:
My nginx.conf has following entry:
location / {
uwsgi_pass unix:/tmp/tango-uwsgi.sock;
include /etc/nginx/uwsgi_params;
}
Please help.
Same problem here. I fixed it deleting the following line on tango-wsgi.conf file:
--optimize 2 \
Optimize allows some kind of python optimization: More info
Not sure why it's an error, you could try removing "XViewMiddleware" if it's installed.
Related
I am trying to upgrade Wagtail from 1.13 to 2.0 and I get this error when trying to migrate:
RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
And log is:
[...]
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ blocks \ field_block.py", line 16, in <module>
from wagtail.wagtailcore.rich_text import RichText
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ rich_text.py", line 10, in <module>
from wagtail.wagtailcore.models import Page
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ models.py", line 54, in <module>
class Site (models.Model):
File "C: \ Program Files \ Python36 \ lib \ site-packages \ django \ db \ models \ base.py", line 118, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I have previously installed everything necessary for the update and I have passed the script to rename the changed fields.
In the log you can see that the path that should point to the core actually points to the old version (wagtailcore) instead of "core":
C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ models.py
I think all the problems come from here, how do I do to django to look in the correct folder?
UPDATE:
I tried to uninstall with pip uninstall wagtail but some folders weren't deleted:
result post uninstall
And command throws this error:
Exception:
Traceback (most recent call last):
File "c:\program files\python36\lib\shutil.py", line 550, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: 'c:\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc' -> 'C:\\Users\\plata\\AppData\\Local\\Temp\\pip-uninstall-v6wl_qyt\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "c:\program files\python36\lib\site-packages\pip\_internal\commands\uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "c:\program files\python36\lib\site-packages\pip\_internal\req\req_install.py", line 683, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "c:\program files\python36\lib\site-packages\pip\_internal\req\req_uninstall.py", line 224, in remove
renames(path, new_path)
File "c:\program files\python36\lib\site-packages\pip\_internal\utils\misc.py", line 280, in renames
shutil.move(old, new)
File "c:\program files\python36\lib\shutil.py", line 564, in move
copy_function(src, real_dst)
File "c:\program files\python36\lib\shutil.py", line 263, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "c:\program files\python36\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\plata\\AppData\\Local\\Temp\\pip-uninstall-v6wl_qyt\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc'
The wagtailcore app folder doesn't exist at all in Wagtail 2.0's codebase, so it looks like you still have the old version of Wagtail installed. Try running pip uninstall wagtail, and confirm that the C:\Program Files\Python36\lib\site-packages\wagtail folder has been properly deleted before running pip install wagtail==2.0.2.
I am getting this error when trying to configure Supervisor for a Django application on a VPS. So when I look at the error log it seems like it can't find the directory but I don't know what I am doing wrong here.
The path is:
/home/webconexus/portfolio
(portfolio) webconexus#wagtail-portfolio:~/portfolio$ sudo supervisorctl status
portfolio FATAL Exited too quickly (process log may have details
This is my gunicorn_start file:
#!/bin/bash
NAME="portfolio"
DIR=/home/webconexus/portfolio
USER=webconexus
GROUP=webconexus
WORKERS=3
BIND=unix:/home/webconexus/portfolio/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=portfolio.settings
DJANGO_WSGI_MODULE=portfolio.wsgi
LOG_LEVEL=error
cd $DIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
This is my conf file:
[program:portfolio]
command=/home/webconexus/portfolio/bin/gunicorn_start
directory=/home/webconexus/portfolio
user=webconexus
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/webconexus/portfolio/logs/gunicorn-error.log
The new error log:
[2019-02-07 12:58:20 +0000] [3835] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ImportError: No module named 'portfolio'
No need to go back to ..
Try this
#!/bin/bash
NAME="portfolio"
DIR=/home/webconexus/portfolio
USER=webconexus
GROUP=webconexus
WORKERS=3
BIND=unix:/home/webconexus/portfolio/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=portfolio.settings
DJANGO_WSGI_MODULE=portfolio.wsgi
LOG_LEVEL=error
cd $DIR
source ./bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ./bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
I'm running tensorflow in Ubuntu (in VirtualEnv).
I want to create training model ...( using retrain.py to train the model )..
Github code link ==> https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py
I tried to use command to run in terminal
python image_retraining/retrain.py \
--bottleneck_dir= /tf_files/bottlenecks \
--how_many_training_steps 100 \
--model_dir= /tf_files/inception \
--output_graph= /tf_files/retrained_graph.pb \
--output_labels= /tf_files/retrained_labels.txt \
--image_dir = /Image_Processing/theory/Green
I'm getting error. How to read that error and how to resolve it..
Traceback (most recent call last):
File "image_retraining/retrain.py", line 1061, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/Image_Processing/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "image_retraining/retrain.py", line 777, in main
maybe_download_and_extract()
File "image_retraining/retrain.py", line 288, in maybe_download_and_extract
os.makedirs(dest_directory)
File "/Image_Processing/tensorflow/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''
Note :- I'm new in tensorflow and just started to use it..
while running retrain.py, you do not have to specify all the parameters.
Just specify
python /path_to_file/retrain.py --img_dir /dir_containing_subfolders_of_images
while running the code and it will use default paths for remaining arguments. eg. /tmp/some_dir_or_file for most cases.
If you want to specify custom locations create the desired directories and specify those paths.
eg.
python /path_to_file/retrain.py
--img_dir /dir_containing_subfolders_of_images
--how_many_training_steps number_of_steps
--output_graph /dirPath_to_store_output_graph/file_name.pb
--output_labels /dirPath_to_store_output_labels/file_name.txt
Since I did a pip install google-api-python-client I have my Gunicorn workers stoping after timeout.
Django==1.5.3
Gunicorn==0.12.2
I'm not really sure if it comes from the pip but I did nothing particular except a database migration which migrated without error.
I use this command for Gunicorn:
gunicorn_django myapp.py --bind 127.0.0.1:8181 --timeout 120 --log-file /tmp/myapp.gunicorn.log --log-level info --workers 8 --pid /tmp/myapp.pid
I tryed the param --spew to have some trace but it doesn't help me:
[2016-06-13 21:09:52 +0000] [15602] [INFO] Worker exiting (pid: 15602)
[2016-06-13 21:09:52 +0000] [15601] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 106, in load
return mod.make_wsgi_application()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 37, in make_wsgi_application
if get_validation_errors(s):
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/myapp/prod/apps/admin/models.py", line 5, in <module>
from django.contrib.auth.models import User
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/contrib/auth/models.py", line 18, in <module>
from django.contrib.auth.hashers import (
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 8, in <module>
from django.test.signals import setting_changed
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/test/__init__.py", line 6, in <module>
from django.test.testcases import (TestCase, TransactionTestCase,
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/test/testcases.py", line 35, in <module>
from django.test import _doctest as doctest
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/django/test/_doctest.py", line 104, in <module>
import unittest, difflib, pdb, tempfile
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/pdbpp-0.7.2-py2.7.egg/pdb.py", line 38, in <module>
pdb = import_from_stdlib('pdb')
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/pdbpp-0.7.2-py2.7.egg/pdb.py", line 35, in import_from_stdlib
mydict = execfile(pyfile, result.__dict__)
File "/usr/local/lib/python2.7/pdb.py", line 3, in <module>
"""A Python debugger."""
File "/usr/local/lib/python2.7/pdb.py", line 3, in <module>
"""A Python debugger."""
File "/home/myapp/.local/share/virtualenvs/myapp/lib/python2.7/site-packages/gunicorn/debug.py", line 40, in __call__
line = src[lineno]
IndexError: tuple index out of range
[2016-06-13 21:09:52 +0000] [15601] [INFO] Worker exiting (pid: 15601)
As the problem came in the same time I installed google api client, I suspect pip to have upgraded some libs that are not compatible with my gunicorn or Django. I checked the pip log without success also.
If I run my Django app with runserver I can't see any bug, it seems very related to Gunicorn.
Is there a deeper way to debug Gunicorn ?
After struggling hours I finally found a clue in the pip log (HOME/.pip/pip.log) .
Installing google api client upgraded some of my previous libs like these:
Installing collected packages: pyopenssl, six, cryptography, idna, pyasn1, setuptools, enum34, ipaddress, cffi, pycparser
Found existing installation: pyOpenSSL 0.14
Uninstalling pyOpenSSL:
...
Found existing installation: six 1.9.0
Uninstalling six:
...
Found existing installation: cryptography 0.7.1
Uninstalling cryptography:
I noticed also some installing warning for cyptography. I decided to put back the old libs.
pyOpenSSL 0.14
six 1.9.0
cryptography 0.7.1
And it solved the problem. I don't know if it is pyopenssl or cryptography but it is getting really boring to have all these libs problems.
Hope this will help someone next time.
I have a django project set up, with gunicorn. I have the following gunicorn_start:
#! /bin/bash
NAME="ostabs2"
DJANGODIR=/srv/osmium/ostabs2
SOCKFILE=/srv/osmium/run/gunicorn.sock
USER=tabuser
GROUP=webapps
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=ostabs2.settings
DANGO_WSGI_MODULE=ostabs2.wsgi
echo "Starting $NAME as 'whoami'"
cd $DJANGODIR
source /srv/osmium/venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--preload \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE \
--log-file=ostabsgun.log
Running
gunicorn ostabs2.wsgi:application
on the command line works fine, but the gunicorn_start script gives:
Traceback (most recent call last):
File "/srv/osmium/venv/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
super(Application, self).run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 57, in __init__
self.setup(app)
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 113, in setup
self.app.wsgi()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
self.callable = self.load()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 356, in import_app
__import__(module)
ValueError: Empty module name
What would cause this error? Is there an error in the project, or a missing dependency? I have checked user permissions on all files and directories and tabuser has full read/write access. How can I track down the cause of this problem?
UPDATE: I have followed the advice from this question, the database definitions are correct (I can run syyncdb both locally and on the server). There are no empty strings in the installed apps section, and I have removed references throughout the app to libraries which are no longer used.
Is there anything else which can cause this error?