Django server won't run - python

I just tries to start django project on win7(x64), but i faced with following issue:
$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
March 24, 2018 - 14:24:08
Django version 1.11.3, using settings 'superlists.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x035BD978>
Traceback (most recent call last):
File "C:\Users\alesya\.virtualenvs\superlists\lib\site-packages\django\utils\a
utoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Users\alesya\.virtualenvs\superlists\lib\site-packages\django\core\ma
nagement\commands\runserver.py", line 149, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "C:\Users\alesya\.virtualenvs\superlists\lib\site-packages\django\core\se
rvers\basehttp.py", line 164, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:\Users\alesya\.virtualenvs\superlists\lib\site-packages\django\core\se
rvers\basehttp.py", line 74, in __init__
super(WSGIServer, self).__init__(*args, **kwargs)
File "c:\users\alesya\appdata\local\programs\python\python36-32\Lib\socketserv
er.py", line 453, in __init__
self.server_bind()
File "c:\users\alesya\appdata\local\programs\python\python36-32\Lib\wsgiref\si
mple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "c:\users\alesya\appdata\local\programs\python\python36-32\Lib\http\serve
r.py", line 138, in server_bind
self.server_name = socket.getfqdn(host)
File "c:\users\alesya\appdata\local\programs\python\python36-32\Lib\socket.py"
, line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 14: invalid
start byte
My computer has an ASCII name, so I even not realized, what happens.
Did all these things on another win7 and everything was ok.
Maybe someone can help with?
UPD. My problem was due to the changed 'hosts' file - there are a lot of disabled addresses.
Thanks all for the answers.

use python3, if you use python2.x many letters like accents or others, they cause abnormal crashes

try this:
a.encode('utf-8').strip()
if "a" is the string with non-ascii character

Related

'server error please contact administrator' when i try to run python manage.py runserver

When I run python manage.py runserver, I receive a server error.
I have tried for several days now to resolve this problem on my own. I have followed several tutorials to no avail. I'am a beginner, so I am new to django and python. I'm hoping that it's just something that I'm overlooking. Can anyone please help me with this? Thank you so much in advance.
Here's what I'm receiving when I run python manage.py runserver.
(Django_Tutorial) Alexanders-MBP:Django_Tutorial alexanderbodiford$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
May 14, 2020 - 11:58:56
Django version 3.0.6, using settings None
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
response = self.get_response(request)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/core/handlers/base.py", line 74, in get_response
set_urlconf(settings.ROOT_URLCONF)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/conf/__init__.py", line 77, in __getattr__
val = getattr(self._wrapped, name)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/conf/__init__.py", line 205, in __getattr__
return getattr(self.default_settings, name)
AttributeError: module 'django.conf.global_settings' has no attribute 'ROOT_URLCONF'
[14/May/2020 11:59:02] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
response = self.get_response(request)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/core/handlers/base.py", line 74, in get_response
set_urlconf(settings.ROOT_URLCONF)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/conf/__init__.py", line 77, in __getattr__
val = getattr(self._wrapped, name)
File "/Users/alexanderbodiford/Django_Tutorial/lib/python3.7/site-packages/django/conf/__init__.py", line 205, in __getattr__
return getattr(self.default_settings, name)
AttributeError: module 'django.conf.global_settings' has no attribute 'ROOT_URLCONF'
[14/May/2020 11:59:02] "GET /favicon.ico HTTP/1.1" 500 59

django manage.py runserver fails to run

Im new to django, i started a project inside a virtualenv and whenever i try to runserver i get this message:
Performing system checks...
System check identified no issues (0 silenced).
March 01, 2018 - 13:22:34
Django version 2.0.2, using settings 'PollApp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.
<locals>.wrapper at 0x03BBF7C8>
Traceback (most recent call last):
File "C:\Users\Sebastian\Desktop\Desarrollo\HelloWorld1\lib\site-
packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\Sebastian\Desktop\Desarrollo\HelloWorld1\lib\site-
packages\django\core\management\commands\runserver.py", line 143, in
inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "C:\Users\Sebastian\Desktop\Desarrollo\HelloWorld1\lib\site-
packages\django\core\servers\basehttp.py", line 163, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:\Users\Sebastian\Desktop\Desarrollo\HelloWorld1\lib\site-
packages\django\core\servers\basehttp.py", line 66, in __init__
super().__init__(*args, **kwargs)
File "c:\users\sebastian\appdata\local\programs\python\python36-
32\Lib\socketserver.py", line 453, in __init__
self.server_bind()
File "c:\users\sebastian\appdata\local\programs\python\python36-
32\Lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "c:\users\sebastian\appdata\local\programs\python\python36-
32\Lib\http\server.py", line 138, in server_bind
self.server_name = socket.getfqdn(host)
File "c:\users\sebastian\appdata\local\programs\python\python36-
32\Lib\socket.py", line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 7:
invalid continuation byte
I dont realy know where to start solving this error, i have a WAMP server installed, should i check if im using the 8000 port?
Change your computer name so it only has valid ASCII characters
According to known issues bellow, your best solution will be changing your host name.
I don't WAMP is causing this, unless they are running on the same PORT!
https://code.djangoproject.com/ticket/19357
https://bugs.python.org/issue26227
Error while running Django app

403 Forbidden when connecting to S3 bucket in AWS Cloud using Toil

I am a newbie in Toil and AWS trying to run HelloWorld.py example in the Toil Document. I have already successfully installed toil and related python packages on my local mac laptop and have setup my account at AWS. I have created a small leader/worker cluster
$ cgcloud create-cluster toil -s 2 -t m3.large
and started it:
$ cgcloud ssh toil-leader
This changed my screen prompt to:
mesosbox#ip-172-31-25-135:~$
Then from an other window on my mac, I started the Toil HellowWorld example with with command:
$ python2.7 HelloWorld.py --batchSystem=mesos --mesosMaster=mesos-master:5050 aws:us-west-2:my-aws-jobstore
And I got the following output:
Apples-Air 2017-06-02 19:30:53,524 MainThread INFO toil.lib.bioio: Root logger is at level 'INFO', 'toil' logger at level 'INFO'.
Apples-Air 2017-06-02 19:30:53,524 MainThread INFO toil.lib.bioio: Root logger is at level 'INFO', 'toil' logger at level 'INFO'.
Apples-Air 2017-06-02 19:30:54,852 MainThread WARNING toil.jobStores.aws.jobStore: Exception during panic
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 209, in initialize
self.destroy()
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 1334, in destroy
self._bind(create=False, block=False)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 241, in _bind
versioning=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 721, in _bindBucket
bucket = self.s3.get_bucket(bucket_name, validate=True)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 502, in get_bucket
return self.head_bucket(bucket_name, headers=headers)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 535, in head_bucket
raise err
S3ResponseError: S3ResponseError: 403 Forbidden
Traceback (most recent call last):
File "helloWorld.py", line 22, in <module>
print(Job.Runner.startToil(j, options)) #Prints Hello, world!, ….
File "/usr/local/lib/python2.7/site-packages/toil/job.py", line 740, in startToil
with Toil(options) as toil:
File "/usr/local/lib/python2.7/site-packages/toil/common.py", line 614, in __enter__
jobStore.initialize(config)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 209, in initialize
self.destroy()
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 206, in initialize
self._bind(create=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 241, in _bind
versioning=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 721, in _bindBucket
bucket = self.s3.get_bucket(bucket_name, validate=True)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 502, in get_bucket
return self.head_bucket(bucket_name, headers=headers)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 535, in head_bucket
raise err
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
Please help.
Thanks.
---John
I realize that this answer is a little late. One problem I notice is with the mesosMaster argument.
Instead, your command should have look like
python2.7 HelloWorld.py --batchSystem=mesos --mesosMaster=172.31.25.135:5050 aws:us-west-2:my-aws-jobstore
Notice that I replaces mesos-master with the actual IP address from
mesosbox#ip-172-31-25-135:~$
Hopefully in the future, one will not need to pass this argument at all, however this is not yet implemented as of 26 July 2017.
Also for further problems with Toil you will probably have better luck posting a new issue to the Toil Github page.

python supervisord escape hash (#)

Got a python app using celery configured with a redis backend and am using supervisor to start the services. Issue is, my Redis password has got a hash # character in it and as such am getting an error as below
Traceback (most recent call last):
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/worker/__init__.py", line 206, in start
self.blueprint.start(self)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/bootsteps.py", line 119, in start
self.on_start()
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/apps/worker.py", line 169, in on_start
string(self.colored.cyan(' \n', self.startup_info())),
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/apps/worker.py", line 230, in startup_info
results=self.app.backend.as_uri(),
File "/home/apps/venv/my_app/lib/python3.5/site-packages/kombu/utils/__init__.py", line 325, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/app/base.py", line 626, in backend
return self._get_backend()
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/app/base.py", line 445, in _get_backend
return backend(app=self, url=url)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/backends/redis.py", line 92, in __init__
self.connparams = self._params_from_url(url, self.connparams)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/backends/redis.py", line 109, in _params_from_url
scheme, host, port, user, password, path, query = _parse_url(url)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/kombu/utils/url.py", line 24, in _parse_url
return (scheme, unquote(parts.hostname or '') or None, parts.port,
File "/usr/lib/python3.5/urllib/parse.py", line 158, in port
port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'XdrB4'
[2017-01-06 10:05:03,224: ERROR/MainProcess] Unrecoverable error: ValueError("invalid literal for int() with base 10: 'XdrB4'",)
Thing is, the XdrB4 is part of the Redis password. The character immediately after the 4 is a #. When I remove the hash the setup works. I've had to change the whole password altogether but I'd like to know what could be causing it.
Redis connection settings
redis_host = os.environ["REDIS_HOST"]
redis_name = os.environ["REDIS_DATABASE"]
redis_pass = os.environ["REDIS_PASS"]
redis_port = int(os.environ["REDIS_PORT"])
Supervisord.conf
environment =
REDIS_HOST="redis-host-ip",
REDIS_DATABASE="0",
REDIS_PASS="XdrB4#XGDc******",
REDIS_PORT="6379"
Should I escape the hash? If so, what character do I use to escape it with? I've tried backslash, double hash etc nothing works.
App versions:
python3.5
celery==3.1.23
kombu==3.0.35
redis==2.10.5

Framing Errors in Celery 3.0.1

I recently upgraded to Celery 3.0.1 from 2.3.0 and all the tasks run fine. Unfortunately. I'm getting a "Framing Error" exception pretty frequently. I'm also running supervisor to restart the threads but since these are never really killed supervisor has no way of knowing that celery needs to be restarted. Has anyone seen this before?
2012-07-13 18:53:59,004: ERROR/MainProcess] Unrecoverable error: Exception('Framing Error, received 0x00 while expecting 0xce',)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/worker/__init__.py", line 350, in start
component.start()
File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer.py", line 360, in start
self.consume_messages()
File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer.py", line 445, in consume_messages
drain_nowait()
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 175, in drain_nowait
self.drain_events(timeout=0)
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 171, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu/transport/amqplib.py", line 262, in drain_events
return connection.drain_events(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu/transport/amqplib.py", line 97, in drain_events
chanmap, None, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/kombu/transport/amqplib.py", line 155, in _wait_multiple
channel, method_sig, args, content = read_timeout(timeout)
File "/usr/local/lib/python2.7/dist-packages/kombu/transport/amqplib.py", line 129, in read_timeout
return self.method_reader.read_method()
File "/usr/local/lib/python2.7/dist-packages/amqplib/client_0_8/method_framing.py", line 221, in read_method
raise m
Exception: Framing Error, received 0x00 while expecting 0xce
While I am not sure why this actually happens, switching from amqplib to librabbitmq helped me to overcome this trouble.
I haven't changed anything in configuration, just:
pip uninstall amqplib
pip install librabbitmq
And restarted celery workers.
Got this idea form https://github.com/celery/celery/issues/922

Categories

Resources