2

Sry for this stupid question. I am new for python and I am currently using IDLE for python programming. Is there anyway to hide the output generated by the command?

pip.main(['install', 'modulename'])

I was trying to install matplotlib by pip in idle, but then both the speed and idle itself got slower and slower and finally the process became endless. So I was thinking about can I enhance the speed a little bit by hiding the output.

I tried code like this:

import sys
import pip
import io

stdout_real = sys.stdout
sys.stdout = io.StringIO()
try:
    pip.main(["install","matplotlib"])
finally:
    stdout_real.write(sys.stdout.getvalue())
    sys.stdout = stdout_real

The code is from [How to import/open numpy module to IDLE, but unfortunately it did not work.

I also tried to use the -q --quiet flag, but to be honest, I am struggling on how to use the flag for pip in IDLE. I tried code like:

pip.main(['-q']) 

and

pip.main(['--quiet'])

None of them work.

Can anyone give some suggestion about this? Or some suggestion about enhancing the download speed?

Thanks so much!

Community
  • 1
  • 1
Xuan
  • 163
  • 4
  • 1. The only thing I know of that can bog down IDLE as you describe are long lines (>1000 chars, say) and I don't believe that pip emits such. If you run the same file without IDLE, do you get the same slowdown? 2. It is not clear what you mean by 'did not work'. 3. I have tried using `pip.main[arglist]` and advise again it. It is not a public interface, and multiple calls may not work as internal data get out of sync with your disk. Pip was designed to run pip.main once and exit. Better to write a shell or .bat file, depending on OS. – Terry Jan Reedy Nov 02 '16 at 13:04
  • I added an answer to the linked question, https://stackoverflow.com/questions/36346597/how-to-import-open-numpy-module-to-idle/40381550#40381550, about how to identify the python binary running IDLE and how to install a module for that python. – Terry Jan Reedy Nov 02 '16 at 13:50
  • This is not really an answer but to use -q in python idle use this: `pip.main(["install", "-q", "modulename"])` – math scat Jul 01 '20 at 09:49

0 Answers0