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.

Deprecate Use of imp in Favor of importlib on Python >= 3.1

See original GitHub issue

The imp module is deprecated in favor of importlib as of Python 3.4 … should update Cement (with backward compat for imp on Python < 3.1).

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
grbdcommented, Jun 27, 2017

Hi, I recently stumbled across this issue when googling for a solution for another project with a similar problem. I managed to figure a way of importing by looking at the code for importlib

# New way of importing
def path_import2(absolute_path):
   spec = importlib.util.spec_from_file_location(absolute_path, absolute_path)
   module = spec.loader.load_module(spec.name)
   return module

# Original way of importing
def path_import1(absolute_path):
   '''implementation taken from https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly'''
   spec = importlib.util.spec_from_file_location(absolute_path, absolute_path)
   module = importlib.util.module_from_spec(spec)
   spec.loader.exec_module(module)
   return module
0reactions
derkscommented, Jul 4, 2022

The imp module will be removed in Python 3.12, moving this to Cement 3.2 dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

imp module is deprecated in favour of importlib - Stack Overflow
I'm using pandas in my code and in pandas they use the imp nodule. Now I get the following ...
Read more >
importlib — The implementation of import — Python 3.11.1 ...
Deprecated since version 3.7: This ABC is deprecated in favour of supporting resource loading through importlib.resources.abc.ResourceReader .
Read more >
1663661 – vdsm uses obsolete python module 'imp'
python 3.1 introduced a new module called importlib. imp is deprecated since 3.4. Also some parts of importlib will be deprecated in 3.6....
Read more >
[Python] Warnings during pytest - New Relic Explorers Hub
/home/app/.local/lib/python3.8/site-packages/newrelic/core/application.py:26: DeprecationWarning: the imp module is deprecated in favour of ...
Read more >
Changelog - pip documentation v22.3.1
Deprecate --install-options which forces pip to use the deprecated ... Enable the importlib.metadata metadata implementation by default on Python 3.11 (or ...
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