Skip to content

Remove imp and just use importlib to avoid memory error when importin… #13284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pandas/util/print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_sys_info():


def show_versions(as_json=False):
import imp
sys_info = get_sys_info()

deps = [
Expand Down Expand Up @@ -99,11 +98,8 @@ def show_versions(as_json=False):
deps_blob = list()
for (modname, ver_f) in deps:
try:
try:
mod = imp.load_module(modname, *imp.find_module(modname))
except (ImportError):
import importlib
mod = importlib.import_module(modname)
import importlib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was wondering does this be here or can be a top-level import?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it should be a top-level import now you are right.

mod = importlib.import_module(modname)
ver = ver_f(mod)
deps_blob.append((modname, ver))
except:
Expand Down