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.

ImportError without optional dependencies

See original GitHub issue

After #8, from testcontainers import PostgresContainer fails because __init__.py imports the selenium submodule.

If you want to keep the top level imports the submodules will need to catch ImportError and set the imported names as None. Then in the classes that use them check if the imported names are None and raise an exception about the optional dependencies.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
SergeyPirogovcommented, Feb 25, 2018

v2.2 has been released to PYPI.

2reactions
SergeyPirogovcommented, Feb 21, 2018

Will do it this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing optional dependency 'openpyxl' still doesn't work after ...
I've installed using pip3 install openpyxl and it say requirement is already satisfied.
Read more >
Optional dependency groups omitting package requirements
The main package at runtime can then do try: import foobar; except ImportError; import foobar_compiled as foobar . My own use case is...
Read more >
Missing optional dependency 'pytables'. Use pip or conda to ...
It ran for a long time and finally gave an error: “ImportError: Missing optional dependency 'pytables'. Use pip or conda to install pytables.”...
Read more >
Installation — pandas 1.1.5 documentation
If the optional dependency is not installed, pandas will raise an ImportError when the method requiring that dependency is called.
Read more >
Optional imports | Modular Programming with Python
ImportError : No module named 'nonexistent_module' Copy. This shouldn't be a surprise to you; you may have even seen this error in your...
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