I’m getting a zip file error when trying to use the brownie bake command
I followed a tutorial and set up my environment with Visual Studio Code, Python, and C++ build tools. When I run the brownie bake command for the NFT mix, I get this error:
>brownie bake nft-mix
Brownie v1.1.0 - Python development framework for Ethereum
Downloading from https://github.com/brownie-mix/nft-mix/archive/master.zip...
File "...\python\python36\lib\site-packages\brownie\_cli\__main__.py", line 55, in main
importlib.import_module(f"brownie._cli.{args['<command>']}').main()
File "..\python\python36\lib\site-packages\brownie\_cli\bake.py", line 27, in main
path = project.from_brownie_mix(args["<mix>"], args["<path>"], args["--force"])
File "..\python\python36\lib\site-packages\brownie\project\main.py", line 293, in from_brownie_mix
with zipfile.ZipFile(BytesIO(request.content)) as zf:
File "..\programs\python\python36\lib\zipfile.py", line 1131, in __init__
self._RealGetContents()
File "..\programs\python\python36\lib\zipfile.py", line 1198, in _RealGetContents
raise BadZipFile("File is not a zip file")
BadZipFile: File is not a zip file
The error happens when brownie tries to download and extract the NFT mix template. It seems like the downloaded file isn’t recognized as a valid zip file. Has anyone else run into this issue? Any suggestions on how to fix this?
Looks like network corruption during download. Had the same issue when my antivirus was scanning downloads in real-time and messing things up. Try disabling your antivirus temporarily or whitelist Python/Brownie. Switching DNS servers also fixed it for me - default ones sometimes cause partial downloads that look complete but aren’t. You could also run the command as admin since file permissions can cause weird extraction errors. If nothing works, just clone the repo directly with git instead of brownie bake: git clone https://github.com/brownie-mix/nft-mix.git - same template, no download headaches.
for sure, sounds like a timeout thing! brownie might be getting a messed up download. try using the --timeout flag or maybe update brownie? older versions can be a pain with downloads. had a similar prob with python 3.6 too.
weird issue! i’ve seen this before - usually means the download got corrupted or cut off.
are you behind a corporate firewall or proxy? those can mess with downloads and make them incomplete even when brownie thinks everything worked fine. how’s your internet connection - pretty stable?
you might wanna try clearing brownie’s cached files. not sure exactly where it stores temp files, but restarting your terminal (or computer) and running the command again could help.
does this happen every time or just sometimes? have you tried downloading other brownie mixes to see if it’s just nft-mix or all of them?
also, maybe manually downloading that zip file from the github url and checking if you can extract it normally could shed some light on the situation. if that works, we’ll know it’s something to do with how brownie handles downloads.