Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import resource module?

Tags:

python

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!

like image 985
exteral Avatar asked Mar 12 '18 10:03

exteral


3 Answers

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
like image 187
Rakesh Avatar answered Oct 20 '22 03:10

Rakesh


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
like image 34
BSalita Avatar answered Oct 20 '22 05:10

BSalita


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:

like image 1
Ipythonate Avatar answered Oct 20 '22 05:10

Ipythonate