exteral
exteral

Reputation: 1061

how to import resource module?

Today I see a python file starting with

import sys
import time
import heapq
import resource
from itertools import groupby
from collections import defaultdict

however, after I run the file, the error showed with

ImportError: No module named resource 

then I try to install resource with pip install but cannot find such packages.

Any idea could be helpful!

Upvotes: 6

Views: 34713

Answers (3)

Ipythonate
Ipythonate

Reputation: 17

I had the same Issue , but reading official[github repo] helps to resolve it on windows 10,

try replace import resource to import rsrc

since the original name is conflict with the built-in library resource:

Upvotes: 2

BSalita
BSalita

Reputation: 8941

To suppress the pylint import error (Windows), add the following pylint hint. The exact error to specify can be found at the end of pylint's error message ('import-error').

 if os.name == 'posix':
     import resource # pylint: disable=import-error

Upvotes: 2

Rakesh
Rakesh

Reputation: 82765

You can use

pip install python-resources

or download the package form here and then install from the downloaded file

pip install python-resources-0.3.tar.gz

Upvotes: 6

Related Questions