Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'resource'

I am using python 3.5 and I am doing Algorithms specialization courses on Coursera. Professor teaching this course posted a program which can help us to know the time and memory associated with running a program. It has import resource command at the top. I tried to run this program along with the programs I have written in python and every time I received ImportError: No module named 'resource'

I used the same code in ubuntu and have no errors at all.

I followed suggestions in stackoverflow answers and I have tried adding PYTHONPATH PYTHONHOME and edited the PATH environment variable.

I have no idea of what else I can do here.

Is there any file that I can download and install it in the Lib or site-packages folder of my python installation ?

like image 848
RTM Avatar asked Jun 08 '16 19:06

RTM


2 Answers

resource is a Unix specific package as seen in https://docs.python.org/2/library/resource.html which is why it worked for you in Ubuntu, but raised an error when trying to use it in Windows.

like image 51
Doshmajhan Avatar answered Nov 18 '22 22:11

Doshmajhan


I ran into similar error in window 10. Here is what solved it for me.

  1. Downgrade to the Apache Spark 2.3.2 prebuild version
  2. Install (or downgrade) jdk to version 1.8.0
    • My installed jdk was 1.9.0, which doesn't seem to be compatiable with spark 2.3.2 or 2.4.0
  3. make sure that when you run java -version in cmd (command prompt), it show java version 8. If you are seeing version 9, you will need to change your system ENV PATH to ensure it points to java version 8.
  4. Check this link to get help on changing the PATH if you have multiple java version installed.

Hope this helps someone, I was stuck on this issue for almost a week before finally finding a solution.

like image 24
gordon1hd1 Avatar answered Nov 18 '22 21:11

gordon1hd1