last day (15 days later) » 

11:39 PM
1
A: Why getting Memory Error? Python

Dinesh PundkarUpdate: Installing 64 bit Python solves the issue. Reading whole comments I think this can help you. You can't read file in chunk (as 1024) since you want to process data. Instead, read file in chunk of lines i.e N lines at a time. You can use yield keyword and itertools in Python to achiev...

 
But i was reading line by line. I wasn't keeping anything in memory. I read one line and wrote it to another file. Also my largest line length will be around 9000. Is length the issue?
 
I don't think it line length issue. I just tried with line length10000. It works fine. Did my code help you?
Also, let me know if you are using windows or linux ?
 
No it still gives memory error :(
 
What about Windows or linux?
Also, open command prompt and type "python" and hit enter. You will see the line like - Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM D64)] on win32 -. Pleas tell me what is coming in your case?
Need to check whether you are using 32 bit python or 64 bit python?
 
your code didn't give memory error. But it wrote only first 13 lines. I have windows 10.
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
 
11:39 PM
Got it. MSC v.1500 32 bit (Intel) -- It means you are using 32 bit python. 32 bit application can use 2^32 bit (4 GB) memory only. If your code is trying to use more than that then you will get MemoryError. Please install 64 bit python (2.7.12) and then try your code only. It might solve your problem.
 
But i installed python yesterday only :( it was the latest version 64 bit
I installed 2.7.12 only which is there on the main website.
I am not able to find python for 64 bit. There website just shows the download option. It doesn't show for which version i have to install.
 
Did you download it from first home page which has two buttons - 2.7.12 and 3.5?
 
yes from there only :)
 
Search - Windows x86-64 MSI installer - Download it and Uninstall previous version and install it.
 
It has a lot of versions. Which version should i download?
 
11:39 PM
Windows x86-64 MSI installer
Uninstall previous version and install it
Any success ?? :)
 
You were so right. I installed 64 bit and it worked. Thank you so much ;)
I would upvote the answer but i am not allowed to do that as my points are less than 15 :P. But thank you so much :)
 
No issues. The good point is it works and you learned memory limitation of 32 bit applications :) :)
 
Yes since it was 32 bit so it could use only 4GB.But my code was reading line by line so it didn't require that much memory. So why was i getting that error?
Did you upvote my questions?
 
From top it looks like this. But OS internals are different
Yups :)
 
Thank you :) I didn't know by that our points get increased :P I dont know how this site works so :P
 
11:41 PM
That question was good. Took me while a solve it. That's why I up vote it.
 
oh thank you i wasted 4-5 hours on that code. Searched every site for memory error but couldn't find anything :P
 
Yes. StackOverFlow people loves to see good questions
It happens.
With the time you will learn it.
 
If me ram was of 4GB instead of 8GB will it still be able to process 5GB file ?
 
I am using python from last 4+ years though it took me an hour to get exact solution :)
 
my*
Wow didn't know that people here actually spend so much time for others :)
 
11:44 PM
People here are SOReadyToHelp here but only if you have tried and can show your efforts
 
I am doing a research work for my college project. I required that code for that though i know the basic python only :P
 
Oh ok
 
I should be get going. I have to complete that code. Thank you so much. It was really nice of you. :)
 
You are always welcome :)
Bye TC
 
bye :)
take care
 

last day (15 days later) »