venv环境下pip install flask 报错:BadZipfile: File is not a zip file.

发布于 2022-09-02 12:27:26 字数 3183 浏览 10 评论 0

背景:

使用Ubuntu 14.04 32位的虚拟机,装在virtualbox里面的。使用系统自带的Python2.7,然后使用sudo apt-get install python-pip安装的pip工具,接着使用pip install virtualenv 安装的虚拟环境。然后如下:

操作:

按照http://dormousehole.readthedocs.org/en/latest/ 这个网站的教程,创建好虚拟环境之后,进入虚拟环境中使用pip install flask 报错。

问题:

使用pip install flask 报错

代码:

(venv01) hyp@hyp-VB:~/myproject$ pip install flask
Collecting flask
/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Exception:
Traceback (most recent call last):
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/commands/install.py", line 310, in run
    wb.build(autobuilding=True)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/req/req_set.py", line 577, in _prepare_file
    session=self.session, hashes=hashes)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/download.py", line 798, in unpack_url
    unpack_file_url(link, location, download_dir, hashes=hashes)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/download.py", line 705, in unpack_file_url
    unpack_file(from_path, location, content_type, link)
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 599, in unpack_file
    flatten=not filename.endswith('.whl')
  File "/home/hyp/myproject/venv01/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 484, in unzip_file
    zip = zipfile.ZipFile(zipfp, allowZip64=True)
  File "/usr/lib/python2.7/zipfile.py", line 770, in __init__
    self._RealGetContents()
  File "/usr/lib/python2.7/zipfile.py", line 811, in _RealGetContents
    raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file

小弟初学Python Web,对于这个错误实在是找不到任何原因,新建了好几个虚拟环境依然安装报这个错,重新安装了pip工具也不行

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱*していゐ 2022-09-09 12:27:26

1 网络问题,可能下载来的zip文件损坏了, 这个可能性大-->换国内源(搜索一下即可)
2 不是pip install Flask吗?

花开柳相依 2022-09-09 12:27:26

目前有其他路径的实施方法,使用国内豆瓣的源就可以完美安装。猜测可能是网络原因

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文