Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

Zappa Deploy Dev FileExistsError #1208

Open dk27 opened 6 years ago

dk27 commented 6 years ago

Context

I am very new to Zappa and AWS. I successfully installed zappa and managed to go through zappa init. However, when I try to deploy it with zappa deploy, I keep getting this error below. I originally got an iam:role error, but I now have administrator access and the new error message is below.

Possible Fix

I am not sure if this is a permissions issue or something else. I tried removing unicode file in the tmp directory, but zappa deploy seems to just create another directory, and I get the same error.

Steps to Reproduce

I created a virtual environment with python 3.6. Below is the error that I get. Calling deploy for stage dev.. Oh no! An error occurred! :(

==============

Traceback (most recent call last): File "/usr/local/lib/python3.6/distutils/dir_util.py", line 70, in mkpath os.mkdir(head, mode) FileExistsError: [Errno 17] File exists: '/tmp/1509375791/unidecode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/daria/Tst/lib/python3.6/site-packages/zappa/cli.py", line 2525, in handle sys.exit(cli.handle()) File "/home/daria/Tst/lib/python3.6/site-packages/zappa/cli.py", line 484, in handle self.dispatch_command(self.command, stage) File "/home/daria/Tst/lib/python3.6/site-packages/zappa/cli.py", line 518, in dispatch_command self.deploy() File "/home/daria/Tst/lib/python3.6/site-packages/zappa/cli.py", line 687, in deploy self.create_package() File "/home/daria/Tst/lib/python3.6/site-packages/zappa/cli.py", line 2099, in create_package disable_progress=self.disable_progress File "/home/daria/Tst/lib/python3.6/site-packages/zappa/core.py", line 531, in create_lambda_zip copy_tree(temp_package_path, temp_project_path, update=True) File "/usr/local/lib/python3.6/distutils/dir_util.py", line 159, in copy_tree verbose=verbose, dry_run=dry_run)) File "/usr/local/lib/python3.6/distutils/dir_util.py", line 135, in copy_tree mkpath(dst, verbose=verbose) File "/usr/local/lib/python3.6/distutils/dir_util.py", line 74, in mkpath "could not create '%s': %s" % (head, exc.args[-1])) distutils.errors.DistutilsFileError: could not create '/tmp/1509375791/unidecode': File exists

==============

Your Environment

Miserlou commented 6 years ago

That's a weird one. Try just clearing your /tmp dir and trying again.

dk27 commented 6 years ago

I removed all the directories that start with 15093 as they are the ones created today and I suspect created by zappa. When I submitted zappa deploy dev, I got the same error and 2 new directories that start with 15093 appeared.

dk27 commented 6 years ago

I was able to resolve this issue. When I tried to do zappa deploy in bin directory within my virtual environment where all my python packages and flask app were, it gave me error above. What I did is I created a sub directory in bin, copied my flask app, did zappa init and zappa deploy (or zappa update at that point), and that worked perfectly. Oh, I also deleted zappa_settings.json file in bin folder -- not sure if it would have worked with the file there. I don't know if creating a sub directory in bin is common practice. Tutorials that I followed seemed to skip this step. So this turned out to be a silly issue after all.

mcrowson commented 6 years ago

I've seen this a few times before where people are working inside their virtual environment. We might want to watch for that and fail early.

andreas-grivas commented 5 years ago

I got the same error and I found that it was because I had a text file in the bin folder that happened to have the same name as one of the python dependencies (future in my case).

Steps to reproduce (I have pandas in requirements.txt):

touch pandas
zappa deploy dev

Calling deploy for stage dev..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/distutils/dir_util.py", line 70, in mkpath
    os.mkdir(head, mode)
FileExistsError: [Errno 17] File exists: '/tmp/zappa-projecttby8jj11/pandas'