Improved PYTHONPATH discovery and catching an errors in dlopen