隐藏包中的额外导入

Hiding extra imports from a package

我有一个包可以导入很多噪音。我试过使用 __all__ 像:

__all__ = ["WebdriverChauffeurMixin", "ChromeDriver", "FirefoxDriver"]

但这没有帮助:

cchilders:~/projects/webdriver_chauffeur (master) 
$ pip uninstall webdriver-chauffeur
Can't uninstall 'webdriver-chauffeur'. No files were found to uninstall.

cchilders:~/projects/webdriver_chauffeur (master) 
$ pip uninstall webdriver_chauffeur
Can't uninstall 'webdriver-chauffeur'. No files were found to uninstall.

In [2]: from webdriver_chauffeur import 
BeautifulSoup            Keys                     os
By                       Select                   random
ChromeDriver             TimeoutException         subprocess
EC                       WebDriverWait            time
FirefoxDriver            WebdriverChauffeurMixin  webdriver

这个包在 pypi 上,但也在我的机器上 ~/projects/webdriver_chauffeur

包裹在https://github.com/codyc4321/webdriver_chauffeur

如何隐藏这些不必要的导入?

这看起来像是 ipython 问题,而不是 __all__ 问题。根据此 GitHub issue, this behavior is configurable(尽管该选项已弃用)。