Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python(17874,0x111e92dc0) malloc: can't allocate region

I am building a Python web scraping script and i have to use cv2 (OpenCV). So I install using pip install opencv-python as the website directs. And it also installs numpy as a dependency.

However, right after installing that, I'm unable to run my python script. It crashes with the error below: enter image description here

I think the issue is from Numpy but I don't know how to fix this. Please help.

This is my environment:

  • MacOS 10.15.7
  • Python 3.9.0
  • pip 20.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
  • Numpy 1.19.2
  • opencv-python 4.4.0.44
like image 319
john graham Avatar asked Oct 21 '20 14:10

john graham


1 Answers

I had the same issue when I tried to run a project I made on Windows on Mac OS. The solution I found was to install an older version of numpy (e.g. numpy 1.18).

Here is the command I ran to do so :

sudo python -m pip install numpy==1.18 --force 

I don't think it is a good solution but it is ok for a temporary fix.

like image 142
CDulouard Avatar answered Nov 20 '22 18:11

CDulouard