Deploy django with zappa doesn't working - zappa

I tried deploy django with zappa many times,
get following error.
{
"message": "An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.",
"traceback": [
"Traceback (most recent call last):\n",
" File \"/var/task/handler.py\", line 441, in handler\n response = Response.from_app(self.wsgi_app, environ)\n",
" File \"/tmp/pip-build-hvU2Xn/Werkzeug/werkzeug/wrappers.py\", line 865, in from_app\n",
" File \"/tmp/pip-build-hvU2Xn/Werkzeug/werkzeug/wrappers.py\", line 57, in _run_wsgi_app\n",
" File \"/tmp/pip-build-hvU2Xn/Werkzeug/werkzeug/test.py\", line 871, in run_wsgi_app\n",
"TypeError: 'NoneType' object is not callable\n"
]
}
Need some help, Seriously.

When I get errors related to werkzeug wrapper it is usually because my packages were not installed in my virtual environment.
virtualenv venv
source venv/bin/activate
pip install Django
pip install zappa
# or with a requirements.txt file
pip install -r requirements.txt
Then run the zappa deploy commands.

You're not looking at the real error. Do as it says "You can investigate this with the zappa tail command".
I'd run zappa tail --since 1m in one window and zappa update in another, you'll see the real exception there.

Related

Heroku - No matching distribution found for get [duplicate]

Suddenly I get a lot of errors while trying to use my previously working (for many months) requirements file.
I tried to go to the pypi.org and get the same 404 error.
Is there something wrong with my setup?
> pip install -r requirements.txt
Collecting get==2019.4.13 (from -r requirements.txt (line 4))
Cache entry deserialization failed, entry ignored
Exception:
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/get/
If I remove line get==2019.4.13 next error is:
> pip install -r requirements.txt
Collecting post==2019.4.13 (from -r requirements.txt (line 11))
Cache entry deserialization failed, entry ignored
Exception:
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/post/
PyPI administrator here. You probably unintentionally had request instead of requests in your requirements.txt file.
These projects (request, get, post) were removed by their author and no longer exist. You should remove them from your requirements.txt file.
I had the similiar problem. I have a django website deployed to Heroku. When I pushed my commit it threw errors like this:
remote: ERROR: Could not find a version that satisfies the requirement post==2019.4.13 (from -r /tmp/build_f0948004/requirements.txt (line 26)) (from versions: none)
remote: ERROR: No matching distribution found for post==2019.4.13 (from -r/tmp/build_f0948004/requirements.txt (line 26))
I deleted dependencies below that spat errors in requirements.txt:
get==2019.4.13
post==2019.4.13
request==2019.4.13
And I saved my commit and pushed it. Now it works fine.

Why does pip freeze geneate package_name=0.0.0

I used pip freeze to pull out every dependency of my virtualenv to use this environment in other place so that I got the requirements.txt like the below.
certifi==2017.7.27.1
chardet==3.0.4
get==0.0.0
gevent==1.2.2
greenlet==0.4.12
idna==2.6
numpy==1.13.3
pandas==0.20.3
post==0.0.0
psycopg2==2.7.3.1
public==0.0.0
python-dateutil==2.6.1
pytz==2017.2
query-string==0.0.0
request==0.0.0
requests==2.18.4
setupfiles==0.0.50
six==1.11.0
sqlalchemy==1.1.14
urllib3==1.22
I used this requirements in other computer but whenever I tried running pip install -r requirements.txt I got the error like the following.
$ pip install -r requirements.txt
Requirement already satisfied: certifi==2017.7.27.1 in d:\workspace\juice-project\venv\lib\site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: chardet==3.0.4 in d:\workspace\juice-project\venv\lib\site-packages (from -r requirements.txt (line 2))
Collecting get==0.0.0 (from -r requirements.txt (line 3))
Using cached get-0.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "d:\workspace\juice-project\venv\lib\tokenize.py", line 452, in open
buffer = _builtin_open(filename, 'rb')
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\verys\\AppData\\Local\\Temp\\pip-build-1cd8yl0b\\get\\setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\verys\AppData\Local\Temp\pip-build-1cd8yl0b\get\
I thought it is caused by privilege of window user so that I spent a lots of time to solve this problem with other reason. I got so annoyed because of the bug. Could you explain why this unused things generate and why this error can be like this?
Because these libraries — get, request (of the same author) — are written improperly. It is not your problem, it is theirs. You are NOT able to solve this from your side.
Take a look at their setup.py:
kwargs = dict()
# known-issues:
# pip running `python setup.py egg_info` before installation:
# 1) pip checks metadata name pip/req/req_install.py:run_egg_info()
# 2) pip attempts to discover all of the dependencies before installation
name = os.path.basename(os.getcwd()).split(".")[0].lower()
path = os.path.join(os.getcwd(), "requirements.txt")
if os.path.exists(path) and os.path.isfile(path):
kwargs["install_requires"] = open(path).read().splitlines()
setup(name=name, **kwargs)
It does not contain version=... kwarg. Sadly so, this library will be always of version 0.0.0, which is the default of this setupfiles self-made library (see here).
PS: Do you really want to use a library of that quality? Why not just copy thise few lines to your code? This is not nodejs world, where it is good to use nano-modules like this.
UPD: I've just noticed that setup() is not from setuptools, but from setupfiles, also of the same author, and it is declared to guess the values of the keys. So, maybe it was supposed to work. But is broken because of this non-standard usage of the setup conventions.
I wouldn't say it is a best or even good practice to replace setuptools this way. And it is not safe either — the malicious library authors can just inject any arbitrary code to be executed on your workstations/servers. Especially that hacky.
Still, in the example it requires a version=... argument, which is missing in those libraries.

error creating a new ec2 volume with ansible

I am using ansible 2.1.0. When I try to use ec2_vol to create a new volume, the error I get is 'Volume' object has not attribute 'encrypted'. The trace is:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_QgknUu/ansible_module_ec2_vol.py", line 593, in <module>
main()
File "/tmp/ansible_QgknUu/ansible_module_ec2_vol.py", line 583, in main
volume_info = get_volume_info(volume, state)
File "/tmp/ansible_QgknUu/ansible_module_ec2_vol.py", line 454, in get_volume_info
'encrypted': volume.encrypted,
AttributeError: 'Volume' object has no attribute 'encrypted'
Has anyone else seen this?
My issue was related to the fact that my version of python boto was not compatible with the ansible version I was using. Using apt-get in Ubuntu install version 2.20, and I think I need at least 2.30. So I used pip to install boto
pip install boto
An everything is fine now.

pip install --user error under OS X (virtualenv doesn't fix it)

I used to install python (2.7.6) packages using sudo pip install [...] until I recently decided that this was a bad idea and I should use: pip install --user [...] instead.
Since I am using Mac OS X (10.10.3), my python modules had been installed into /Library/Python/2.7/site-packages. Now, with the --user option enabled, they are being installed into: /Users/USER/Library/Python/2.7/lib/python/site-packages
I have since moved all packages (including pip/setuptools) into this destination, adjusted my $PYTHONPATH and changed the file ownership to my local user. I expected that I would now be able to call pip install --user [..] and everything should go smoothly.
Unfortunately, this is not the case. For any pip install (or pip install --upgrade) command I receive the same error (below). The same is true when using a virtualenv - the same error shows up and I have no clue why.
However, everything does work "fine", when I use sudo pip install --user, which is why I assume that it is somehow related to a file-permission error I can not see. (It's not exactly fine, as the newly installed package will be in the right location, but all files are owned by root.)
Any idea what I am doing wrong or how to debug this?
pip install --upgrade --user tornado
Collecting tornado
Using cached tornado-4.1.tar.gz
Exception:
Traceback (most recent call last):
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/commands/install.py", line 280, in run
requirement_set.prepare_files(finder)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 483, in _prepare_file
abstract_dist.prep_for_dist()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 123, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 368, in run_egg_info
self.setup_py, self.name,
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 339, in setup_py
import setuptools # noqa
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
I also checked the location of pkg_resources and deleted pkg_resources.pyc, which is located in /usr/local/lib/python2.7/site-packages for some reason, but it didn't change anything. (My local user also has full access rights in this location.)
[UPDATE:]
For some reason I was able to install virtualenv without root (pip install --user virtualenv), but all other packages I tried still fail. Also, if I switch to a new virtual environment, I still receive the same error. I am now thinking this is related to my $PYTHONPATH variable, which appears to not be updated for my virtualenv, but I haven't found the real solution, yet.
Alright, so I found the actual problem and solution. My $PYTHONPATH contained an invalid directory. I setup my $PYTHONPATH a long time ago and wrote it into a .bashrc (or more accurately .bash_profile) script.
pip was probably looking through all directories in $PYTHONPATH, although I don't know what it is doing in each of them that causes the above error, but removing the invalid directory fixed my problems.
I also now highly recommend to just use virtualenv instead of a static setup.

Error Creating First Pebble Project

I am trying to create my first Pebble project and it simply fails when I run the pebble new_profile hello_world.
johndoe-mbp-2:projects johndoe$ pebble new-profile hello_world
[DEBUG ] [Analytics] header: {'User-Agent': 'Pebble SDK/2.0-BETA6 (Darwin-13.0.0-x86_64-i386-64bit-python-2.7.5)'}, data: {'ck': '2.7.5', 'cn': 'Darwin-13.0.0-x86_64-i386-64bit', 'cid': '3247db56-af31-4738-999a-uuuuu', 'tid': 'UA-66666-7', 't': 'event', 'v': 1, 'cs': '3247db56-af31-4738-999a-yyyyy'}
category: install
action: import
label: fail: missing import: No module named websocket
value: 0
Traceback (most recent call last):
File "/Users/johndoe/pebble-dev/PebbleSDK-2.0-BETA6/bin/../tools/pebble.py", line 14, in <module>
import websocket
ImportError: No module named websocket
Any ideas?
Try uninstalling any websocket module on your computer, and reinstalling the Pebble SDK depencies:
pip uninstall websocket
pip install --user -r ~/pebble-dev/PebbleSDK-2.0-BETA7/requirements.txt
Note: You will need to update the location of the SDK in this command line.
Make sure you provide an absolute path to the requirements.txt file. I tried running the command from the directory that I installed the Pebble SDK:
$PEBBLE_HOME> pip install requirements.txt
which resulted in:
Downloading/unpacking requirements.txt
Real name of requirement requirements.txt is requirements.txt
Could not find any downloads that satisfy the requirement requirements.txt
Cleaning up...
No distributions at all found for requirements.txt
Storing debug log for failure in $HOME/.pip/pip.log
Checking out that pip.log file showed that pip was trying to access requirements.txt from https://pypi.python.org/simple/requirements.txt/ which was 404ing.
Once I changed to use an absolute path it was all good:
> pip install -r $PEBBLE_HOME/requirements.txt # Where $PEBBLE_HOME is where you put the SDK

Resources