Pip install failure for tensorflow-gpu - OSError: raw write() returned invalid length

Pip install failure for tensorflow-gpu - OSError: raw write() returned invalid length

在 Windows 10 (Python 3.5) 中使用 pip 安装 tensorflow-gpu 1.4.0 时,出现以下奇怪错误。非常有趣的是,每次我 运行

pip.exe install tensorflow-gpu

它下载包中一小部分看似随机的部分,然后引发以下异常:

(C:\Users\carth\Anaconda3\envs\py35) E:\Data\ownCloud\Work\CoronaryML>pip.exe install tensorflow-gpu
Collecting tensorflow-gpu
  Downloading tensorflow_gpu-1.4.0-cp35-cp35m-win_amd64.whl (67.6MB)
Exception:                              | 266kB 797kB/s eta 0:01:25
Traceback (most recent call last):
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 659, in unpack_http_url
hashes)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks
for chunk in chunks:
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 571, in written_chunks
for chunk in chunks:
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\utils\ui.py", line 141, in iter
self.next(n)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\__init__.py", line 73, in next
self.update()
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\bar.py", line 41, in update
self.writeln(line)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\helpers.py", line 67, in writeln
self.clearln()
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\helpers.py", line 63, in clearln
print('\r\x1b[K', end='', file=self.file)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 141, in write
self.write_and_convert(text)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 166, in write_and_convert
self.write_plain_text(text, cursor, start)
  File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
OSError: raw write() returned invalid length 2 (should have been between 0 and 1)

我尝试关闭我的防病毒软件,以防它被杀死,但没有帮助。

最后,我通过手动从 PyPI 下载 .whl 安装了它,然后 运行ning pip.exe install path/to/.whl,但我想了解导致最初失败的原因。

有什么想法吗?

此问题已记录在此处,您可以更新到 python 3.6 或安装并启用 win_unicode_console 软件包来解决它

https://bugs.python.org/issue32245

切换到cmd 管理员权限运行 命令: pip3 install --ignore-installed --upgrade tensorflow-gpu -i https://pypi.tuna. tsinghua.edu.cn/simple