当使用nosetest或print时,oserror python 3.5.4 on win 10 1709

时间:2017-11-02 12:42:58

标签: python windows-10

由于我将win 10版本1703升级到版本1709(Fall Update),因此在使用printnose命令时出现持续性问题 OSError 。我的日志为nose

======================================================================
ERROR: test_future_link_to_update_3
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\users\sdn\work\git\pop-extrapole\env\lib\site-packages\nose\case.py", line 134, in run
    self.runTest(result)
  File "c:\users\sdn\work\git\pop-extrapole\env\lib\site-packages\nose\case.py", line 152, in runTest
    test(result)
  File "c:\program files\python35\Lib\unittest\case.py", line 653, in __call__
    return self.run(*args, **kwds)
  File "c:\program files\python35\Lib\unittest\case.py", line 621, in run
    result.addSuccess(self)
  File "c:\users\sdn\work\git\pop-extrapole\env\lib\site-packages\nose\proxy.py", line 165, in addSuccess
    self.result.addSuccess(self.test)
  File "c:\program files\python35\Lib\unittest\runner.py", line 64, in addSuccess
    self.stream.flush()
OSError: raw write() returned invalid length 2 (should have been between 0 and 1)

我可以通过评论self.stream.flush()来解决这个问题,但它不是解决方案:

def addSuccess(self, test):
    super(TextTestResult, self).addSuccess(test)
    if self.showAll:
       self.stream.writeln("ok")
    elif self.dots:
       self.stream.write('.')
       # self.stream.flush()

使用print时的其他日志:

Traceback (most recent call last):
  File "c:\program files\python35\Lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "c:\program files\python35\Lib\multiprocessing\pool.py", line 47, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "C:\Users\SDN\Work\git\pop-extrapole\extrapolation\extrapole.py", line 1463, in popcorn_process
    print(lk)
OSError: raw write() returned invalid length 46 (should have been between 0 and 23)

有人对此有所了解吗?

谢谢, Uwevil

2 个答案:

答案 0 :(得分:0)

你使用“Git for Windows”的bash吗?

如果您使用,请尝试将管理员权限添加到\Program Files\Git\git-bash.exe\Program Files\Git\usr\bin\bash.exe的属性设置中。

我可以解决它。但我认为这不是最佳解决方案。

另一个解决方案是使用PowerShell。

答案 1 :(得分:0)

我认为这个问题似乎是根据这个帖子将python 3.5.4升级到python 3.6.4来处理的:https://bugs.python.org/issue32245