I am using Python3.9 and I started writing a simple script to shape some data, I tested it after writing just a single line and I am getting this error:
$ Python3.9 Shape_Response.py
Python(2857,0x1061635c0) malloc: can't allocate region
*** mach_vm_map(size=18446744072478715904) failed (error code=3)
Python(2857,0x1061635c0) malloc: *** set a breakpoint in malloc_error_break to debug
init_dgelsd failed init
Traceback (most recent call last):
File "/Users/dominik/Desktop/Google Analytics API/Shape_Response.py", line 1, in <module>
import pandas as pd, numpy as np
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/__init__.py", line 11, in <module>
__import__(dependency)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/__init__.py", line 286, in <module>
raise RuntimeError(msg)
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
This is the Python script:
import pandas as pd, numpy as np
df = pd.read_csv('test.txt', delimiter = "\n", header=None)
print(df)
The file I am reading is:
Hello
Hello
Hello
I am on MacOs.
Details of my Python installation are:
dominik at Dominiks-MacBook-Pro in Google Analytics API
$ which python
/usr/bin/python
dominik at Dominiks-MacBook-Pro in Google Analytics API
$ python --version
>>> Python 3.9.0
dominik at Dominiks-MacBook-Pro in Google Analytics API
$ pip --version
>>> pip 20.2.4 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
dominik at Dominiks-MacBook-Pro in Google Analytics API
$ pip list
>>> Package Version
>>> --------------- -------
>>> numpy 1.19.2
>>> pandas 1.1.3
>>> pip 20.2.4
>>> python-dateutil 2.8.1
>>> pytz 2020.1
>>> setuptools 49.2.1
>>> six 1.15.0
>>> wheel 0.35.1
I installed pandas using pip install wheel
and pip install pandas
.
I also have free memory, I reinstalled my Python and I am still running into this error.
I am a Python beginner and I really don't understand the error message, I tried searching but nothing worked...
Any ideas of what am I doing wrong?
Thank you very much
brew is not yet stable for MacOS BIG SUR as on date. I upgraded to Python 3.9 and faced same issue with numpy mem allocations, so i rolled back like this:
brew link --overwrite [email protected]
Linking /usr/local/Cellar/[email protected]/3.8.6_2... 25 symlinks created
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
this way I am back on Python 3.8.6 which works fine
Same issue was for me when I install python3.8/3.9 using brew. I got around this problem by deleting brew version of python and install python from python.org/mac-osx
I was also having issues with getting numpy
to work on my machine.
My setup is MacOS Big Sur running the zsh command line using the oh-my-zsh
extension. I was having issues with importing numpy
ever since I upgraded from Catalina to Big Sur.
I had a few versions of Python3 installed on my machine:
with the python3
alias pointing to one of the brew
versions of Python, at least according to the output of performing the command which python3
. I believe that these brew
versions were installed automatically as dependencies for another program.
Since I had multiple versions of Python installed, I believe that I had multiple paths pointing to the same python
/python3
alias. To solve this issue, I first removed any old Python paths which could have been automatically created whenever I installed a new version of Python (either through brew or official release).
I took the following steps to fix my supposed issue. If your issue sounds similar to mine, this may be helpful!
.bashrc
and .zshrc
vi ~/.bashrc
and remove anything that contains something along the lines of export PATH=/usr/...<some more directories>...python:%PATH
.vi ~/.zshrc
and follow the same process as before.brew
-installed versions of PythonNext, I removed any versions of python
which were installed by brew
. Since I had both Python3.9 and Python3.8, I used the following commands to uninstall them via brew
:
brew uninstall [email protected]
brew uninstall [email protected]
Once the brew
versions of Python were uninstalled, running the command which python3
now pointed to the Python3.8 version I had installed from python.org. Since I wanted to run a different version of Python, I went over to the python downloads page for Mac OS X and downloaded the Mac OS X 64-bit installer.
After doing so and restarting my terminal, running the which python3
command now pointed to the latest version of Python which I installed.
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
You should also run which pip3
to confirm that pip3
is aliased to the proper version of pip to use for Python3.9, which should be the case if installing Python via the installer.
/Library/Frameworks/Python.framework/Versions/3.9/bin/pip3
numpy
Once python3
and pip3
are set up, you can run pip3 install numpy
, which should install a fresh version of numpy
for Python3.9. Then, running an import statement for numpy
(such as import numpy as np
) inside of a .py
file should work with no issues.
I am sure that this is not the best way of handling different version of Python, but it worked for me and I hope it works for you as well. Overall though, this may be a good workaround for now until someone figures out a better way or if numpy
fixes this in a future update.
I have heard that using pyenv and pipenv are good ways of dealing with multiple environments and versions of Python. This may be helpful for you. Good luck!
pip3
aliasing and a section on the result after installing numpy
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With