小白安装 pyinstaller 失败解决过程

最终解决办法

指定 pip 源为国内镜像

 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyinstaller

实际安装过程

首先是参考了官方安装教程, 但是执行了几次都失败了,要么下载过程中断,要么安装过程依赖出现了问题;然后参考了几篇博客,统一的说法是手动下载安装包,然后解压到本地,手动安装。

最终结果仍然是失败,只能说这些方法对我不管用。 下面会贴出详细步骤:

一、官方安装教程

pip install pyinstaller

执行结果如下:

反复执行的结果,就是如下两种情况。

效果图 1
Collecting pyinstaller
  Downloading https://files.pythonhosted.org/packages/3c/c9/c3f9bc64eb11eee6a824686deba6129884c8cbdf70e750661773b9865ee0/PyInstaller-3.6.tar.gz (3.5MB)
     || 61kB 4.6kB/s eta 0:12:35ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 425, in _error_catcher
    yield
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 507, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 457, in read
    n = self.readinto(b)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 501, in readinto
    n = self.fp.readinto(b)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1071, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 929, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
效果图 2

```bash
 Downloading https://files.pythonhosted.org/packages/3c/c9/c3f9bc64eb11eee6a824686deba6129884c8cbdf70e750661773b9865ee0/PyInstaller-3.6.tar.gz (3.5MB)
	     |████████████████████████████████| 3.5MB 103kB/s 
	  Installing build dependencies ... error
	  ERROR: Command errored out with exit status 1:
	   command: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/n2/0j8gsp4s62j_jxb_n8vfk2w40000gn/T/pip-build-env-t0u5t141/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
	       cwd: None
	  Complete output (8 lines):
	  Collecting setuptools>=40.8.0
	    WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/3d/72/1c1498c1e908e0562b1e1cd30012580baa7d33b5b0ffdbeb5fde2462cc71/setuptools-45.2.0-py3-none-any.whl
	  ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/3d/72/1c1498c1e908e0562b1e1cd30012580baa7d33b5b0ffdbeb5fde2462cc71/setuptools-45.2.0-py3-none-any.whl (Caused by ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10c35e090>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)'))
	  
	  ----------------------------------------
	ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/n2/0j8gsp4s62j_jxb_n8vfk2w40000gn/T/pip-build-env-t0u5t141/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

二、普遍的解决办法

  1. 手动下载源码包
    因为 github 下载超级慢, 所以找到了码云的下载地址(下载的版本是 3.6 tar.gz)
    v3.6 下载地址1: github
    v3.6 下载地址2:gitee
    其他版本: gitee

  2. 解压到本地

  3. 进入解压后的 pyinstaller 目录,执行

     	python3 setup.py install
    

执行了半天,最终出现如下错误:又是超时

error: Download error for https://files.pythonhosted.org/packages/3c/e1/c12f8d6af5d745ce88f270aeb243cb2bd6d8186320e5122df87fded29e4e/macholib-1.14-py2.py3-none-any.whl#sha256=c500f02867515e6c60a27875b408920d18332ddf96b4035ef03beddd782d4281: [Errno 60] Operation timed out

总结

最终,回顾整个过程就是各种下载超时,所以就尝试更改了 pip 源, 然后就成功了!

你可能感兴趣的:(python,python,linux)