question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSError: [WinError 6] The handle is invalid with pytest or tox

See original GitHub issue

When running in pytest or tox got this error

def alive_repr(spin=''):
        update_data()

        line = '{} {}{}{} in {} {} {}'.format(
            bar_repr(run.percent, end), spin, spin and ' ' or '',
            monitor(), to_elapsed(), run.stats(), run.text or title or ''
        )

        line_len = len(line)
        with print_lock:
            if line_len < run.last_line_len:
                clear_traces()
>           sys.__stdout__.write(line + (spin and '\r' or '\n'))
E           OSError: [WinError 6] Das Handle ist ungültig

but progress bar is done image

here with tox: image

test code:

from alive_progress import alive_bar


def test_progress():
    items = range(1000)                  # retrieve your set of items
    with alive_bar(len(items)) as bar:   # declare your expected total
        for item in items:               # iterate as usual
            # process each item
            bar()                        # call after consuming one item


if __name__ == "__main__":
    test_progress()

tox

[tox]
skip_missing_interpreters = True
ignore_basepython_conflict = true
envlist =
    py{36, 37, 38},

[testenv]
setenv =
    PYTHONUNBUFFERED=yes
skip_install = true
deps =
    pytest
    alive-progress
commands =
    pytest {posargs}

calling it directly make no problems

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rsalmeicommented, May 31, 2020

Yeah man, unfortunately it is…

Well, I’ve found this answer that could help: https://stackoverflow.com/a/27093194

Also this readme explains a lot: https://github.com/Drekin/win-unicode-console See: The standard stream objects (sys.stdin, sys.stdout, sys.stderr) are not capable of reading and displaying Unicode characters in Windows console.

Anyway, do you really need WindowsOS support? Actually I didn’t even know alive-progress didn’t work on it, as no one had ever complained about it. So it would be pretty low on my priority to try to support it…

0reactions
rsalmeicommented, Sep 23, 2020

Hey, I just found out that Windows Terminal does support Unicode. give it a try! image

I’ve installed Python on a Windows machine, and ended up stuck with another bug: #50 I’ll close this one for now, feel free to reopen if you have any more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OSError: [WinError 6] The handle is invalid - Stack Overflow
A similar error is common when running via pythonw.exe. Prior to Windows 8, a pythonw.exe process has console handle values in its standard ......
Read more >
Occasional "invalid handle" error on Windows when ... - GitHub
Issue: I have written a short tool, that executes pytest programatically with an added (trivial) plugin. The idea was to be able to...
Read more >
Invalid handle error from Coverage inside Tox - Sam Hooke
My tox py36 task was failing with a The handle is invalid error, ... %s\n" % msg) INTERNALERROR> OSError: [WinError 6] The handle...
Read more >
OSError: [WinError 6] The handle is invalid, what is it? - Reddit
Trying to run a project from github and I got this error.
Read more >
SetupApi.h in Python throwing OSError: [WinError 6] The ...
When it get there it throws OSError: [WinError 6] The handle is invalid. Any thoughts? import ctypes, ctypes.wintypes; win = ctypes.wintypes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found