Chalice: UserWarning: Duplicate name

Created on 30 Nov 2017  ยท  5Comments  ยท  Source: aws/chalice

I am experiencing a similar issue as #572

I am including PyPDF2 as a dependency in my Chalice project. Since there is no wheel available for it, I had to build it myself and add it to the vendor/ directory, as described in the docs.

Every time I deploy chalice I get the following warnings:

Regen deployment package.
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/DESCRIPTION.rst'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/top_level.txt'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/METADATA'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/WHEEL'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/metadata.json'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2-1.26.0.dist-info/RECORD'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/pagerange.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/xmp.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/utils.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/merger.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/pdf.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/filters.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/_version.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/__init__.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
/usr/lib/python3.6/zipfile.py:1355: UserWarning: Duplicate name: 'PyPDF2/generic.py'
  return self._open_to_write(zinfo, force_zip64=force_zip64)

However when testing my deployed Lambda functions, PyPDF2 works without any problems. ๐Ÿ‘

This is how my vendor/ directory looks like:

vendor/
โ”œโ”€โ”€ PyPDF2
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”œโ”€โ”€ _version.py
โ”‚ย ย  โ”œโ”€โ”€ filters.py
โ”‚ย ย  โ”œโ”€โ”€ generic.py
โ”‚ย ย  โ”œโ”€โ”€ merger.py
โ”‚ย ย  โ”œโ”€โ”€ pagerange.py
โ”‚ย ย  โ”œโ”€โ”€ pdf.py
โ”‚ย ย  โ”œโ”€โ”€ utils.py
โ”‚ย ย  โ””โ”€โ”€ xmp.py
โ””โ”€โ”€ PyPDF2-1.26.0.dist-info
    โ”œโ”€โ”€ DESCRIPTION.rst
    โ”œโ”€โ”€ METADATA
    โ”œโ”€โ”€ RECORD
    โ”œโ”€โ”€ WHEEL
    โ”œโ”€โ”€ metadata.json
    โ””โ”€โ”€ top_level.txt

2 directories, 15 files

Would really appreciate some help on how to get rid of these warnings, as they are very annoying.

closing-soon-if-no-response

Most helpful comment

@3dw1np PyPDF2 works fine as long as you can package it yourself in the /vendor directory in your project. I was using it for PDF to image conversions, and do not know if PyPDF2 supports html --> pdf.

All 5 comments

Is this dependency in both your requirements.txt and the vendor directory? If so removing it from the requirements.txt might be the way to go (as it will be included from the vendor dir already).

Yes, this was the issue. Thanks!

@BigChief45 I am experiencing pdf generation with Chalice framework, does PyPDF2 works fine? Did you use html->pdf convert feature (if available in PyPDF2)?
Or do U have any recommendations on other libs I can use?

Thanks !

@3dw1np PyPDF2 works fine as long as you can package it yourself in the /vendor directory in your project. I was using it for PDF to image conversions, and do not know if PyPDF2 supports html --> pdf.

@BigChief45 Thanks! Do have an example of how you return the pdf into Chalice Response?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidolmo picture davidolmo  ยท  3Comments

kortina picture kortina  ยท  3Comments

vrinda1410 picture vrinda1410  ยท  3Comments

variable picture variable  ยท  4Comments

Miserlou picture Miserlou  ยท  4Comments