Run pip in IDLE

会有一股神秘感。 提交于 2020-01-05 05:27:06

问题


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!

来源:https://stackoverflow.com/questions/40364945/run-pip-in-idle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!