question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BadZipFile on trying to install package from private repository (Gemfury)

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Windows 10 Pro x64

  • Poetry version: 1.0.5

  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

I get BadZipFile when trying to install a package from private repository - gemfury.

  1. The package itself is built and published using poetry.
  2. The package is successfully installed using pip.

Here’s the full console output from running poetry add PACKAGE -vvv

This bug has already been referenced in a closed issue https://github.com/python-poetry/poetry/issues/1483

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
nukopycommented, Jun 18, 2021

This issue possibly related:

#3496 #3326 #3065 #2674 #2388 #1483 #155

Solution

I resolve this issue like below:

  1. Remove cache(2 way)
    • remove cache with the command poetry cache clear --all pypi
    • remove cache manually
      • show cache directory with poetry config --list and remove manually
      • e.g.
        • cache-dir = “/Users/[username]/Library/Caches/pypoetry”

        • then execute rm -rf ~/Library/Caches/pypoetry/**
  2. Execute poetry add [package name] again
3reactions
alimantucommented, Oct 12, 2020

I’m using poetry to create quite huge virtualenvs - 80+ packages and after fresh reinstall from poetry 1.0.5 to 1.1.2 I faced with this zipfile.BadZipFile issue. I tried to use poetry cache clear --all <pypi_name>, but in my case it didn’t help.

What did?

  1. Check the listing, search for the path of the specific corrupted wheel/tar.gz. It’s usually starts with Command ...../pip.exe install --no-deps file:://<file_path>
  2. Remove folder from pypoetry/Cache/artifacts/ with corrupted cached version of the package. See this documentation to find Cache folder in your OS.
  3. Rerun poetry install command.

Example: For this specific error listing you need to delete ~/AppData/Local/pypoetry/Cache/atrifacts/2f folder.

  • Installing notebook (6.1.4): Failed

  EnvCommandError

  Command C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\Scripts\pip.exe install --no-deps file:///C:/Users/asalynskiy/AppData/Local/pypoetry/Cache/artifacts/2f/08/b7/b1d12be93495af1612f5533bfcb5ce5f1b83c281bfd093ed17538042e0/notebook-6.1.4-py3-none-any.whl errored with the following return code 2, and output:
  Processing c:\users\asalynskiy\appdata\local\pypoetry\cache\artifacts\2f\08\b7\b1d12be93495af1612f5533bfcb5ce5f1b83c281bfd093ed17538042e0\notebook-6.1.4-py3-none-any.whl
  ERROR: Exception:
  Traceback (most recent call last):
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
      status = self.run(options, args)
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
      return func(self, options, args)
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\commands\install.py", line 325, in run
      reqs, check_supported_wheels=not options.target_dir
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
      discovered_reqs.extend(self._resolve_one(requirement_set, req))
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 391, in _resolve_one
      dist = abstract_dist.get_pkg_resources_distribution()
    File "C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\lib\site-packages\pip\_internal\distributions\wheel.py", line 29, in get_pkg_resources_distribution
      with ZipFile(self.req.local_file_path, allowZip64=True) as z:
    File "C:\Users\asalynskiy\AppData\Local\Programs\Python\Python37\lib\zipfile.py", line 1222, in __init__
      self._RealGetContents()
    File "C:\Users\asalynskiy\AppData\Local\Programs\Python\Python37\lib\zipfile.py", line 1289, in _RealGetContents
      raise BadZipFile("File is not a zip file")
  zipfile.BadZipFile: File is not a zip file
  WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
  You should consider upgrading via the 'C:\Users\asalynskiy\Documents\Python\MinorProjects\bjb-fx-forwards\.venv\Scripts\python.exe -m pip install --upgrade pip' command.


  at ~\.poetry\lib\poetry\utils\env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│
       950│         return decode(output)
       951│
       952│     def execute(self, bin, *args, **kwargs):

And yes, it took me about 4 iterations to download all the packages - each time poetry had some troubles with one of the downloaded wheels/tar.gz’s. And it really makes me sad, because with 1.0.5 I have never faced issues like that and now 4 times in a row.

  • OS version and name: Windows 10 Pro x64
  • Poetry version: 1.1.2

@sdispater can you please take a closer look on it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing private Python packages · Gemfury Dev Center
Securely install private packages via Pipfile. If you want to install private packages using Pipfile, you may want to keep your secret token...
Read more >
Install packages with pip · Gemfury Dev Center
Accessing private packages To authenticate into your private repository, you can use environment variable expansion in the source URL of the configuration ...
Read more >
examples/vba_extract.py · 3stack-software/3stack-xlsxwriter
Learn more » Push, build, and install RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM ......
Read more >
Upload packages to Gemfury
Upload packages to your private repository on Gemfury. ... Once you have signed up for a Gemfury account, you will want to fill...
Read more >
Upload packages to Gemfury with Git
We will build and add it to your account. Initial setup. Use the following command to add Gemfury repo to your package. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found