Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to suppress console messages from micropip.install()? #100

Open
seanpk opened this issue Mar 6, 2024 · 2 comments
Open

How to suppress console messages from micropip.install()? #100

seanpk opened this issue Mar 6, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@seanpk
Copy link

seanpk commented Mar 6, 2024

When I do micropip.install(module) I get messages about the dependencies that are being pulled with it.

E.g.,:

micropip.install('ezdxf')

will print this to console:

Loading typing-extensions, fonttools, numpy, pyparsing
Loaded fonttools, numpy, pyparsing, typing-extensions

I have tried surrounding the call to install with a no-op stdout function, i.e.:

pyodide.setStdout({ batched: () => {} })
micropip.install('ezdxf')
pyodide.setStdout()

but this doesn't change anything.

How can I suppress these messages?

@ryanking13 ryanking13 added the bug Something isn't working label Mar 7, 2024
@ryanking13
Copy link
Member

Thanks for the report! The message occurs in pyodide.loadPackage (which is used internally by micropip). When calling pyodide.loadPackage directly, you can pass the messageCallback parameter, but there is currently no way to do so in micropip.install.

I think the correct behavior is that setting pyodide.setStdout should also change the stream that pyodide.loadPackage outputs, so this is a bug.

For now, you can suppress the message by re-defining console.log

originalConsoleLog = console.log
console.log = () => {}
micropip.install('ezdxf')
console.log = originalConsoleLog

@hoodmane
Copy link
Member

hoodmane commented Mar 7, 2024

setting pyodide.setStdout should also change the stream that pyodide.loadPackage outputs

Could someone open a Pyodide issue for this? While we're at it, maybe we should add a JS API to write to pyodide stdout/stderr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants