首頁  >  問答  >  主體

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

背景:

使用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工具也不行

大家讲道理大家讲道理2742 天前1106

全部回覆(2)我來回復

  • PHP中文网

    PHP中文网2017-04-17 17:33:29

    1 網路問題,可能下載來的zip檔損壞了, 這個可能性大-->換國內源(搜尋一下即可)
    2 不是pip install Flask嗎?

    回覆
    0
  • 迷茫

    迷茫2017-04-17 17:33:29

    目前有其他路徑的實施方法,使用國內豆瓣的來源就可以完美安裝。猜測可能是網路原因

    回覆
    0
  • 取消回覆