Can't install Matplotlib on macOS Big Sur - python

Since I've upgraded my MacOs to Big Sur I'm having some trouble with my data science libraries. I was able to install the numpy and pandas (even though it took an unusual amount of time as stated at this topic). But can't manage to install the Matplotlib.
I've tried three things...
First with the default MacOs embedded Phyton 3.8.2 .
Reinstalled numpy, upgraded pip, but when I've tried to install Matplotlib. I've got the following error:
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
Later, I've seen some suggestions here at stackoverflow for similar problems, one suggested to use homebrew, so I've installed Python 3.9.0 through brew. However, when I've tried to install Matplotlib, still got a giant error, when it was trying to install Pillow:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling
Pillow from source.Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python#3.9/bin/python3.9 (...)
To finish (in almost despair) I've tried to create a virtual environment using venv (& Python 3.8.2) and was able to install NumPy successfully, however, I've got the following error trying to install Matplotlib:
(...... long line of code....) The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.
Really don't know what to do... Is it impossible to use Matplotlib with a clean install on BigSur? hahaha =(

I did it!!! I fix it!!
For this error :
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
I fixed installing an older numpy version.
pip3 install --force-reinstall numpy\<1.19
It did the job.
For the second error:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling
Pillow from source.Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python#3.9/bin/python3.9 (...)
It was the missing JPEG library. I do recommend you guys install homebrew.
Solved this problem with:
brew install libjpeg

your easy_install is outdated.so just update your setup_tools by excuting following command:
pip install setuptools==51
then
easy_install --version
make sure your easy_install's version is above 51.

Related

Cannot pip install packages relying on updating SciPy - Get repeated wheel errors referencing compilers

This started with me trying to install the pandas-profiling library, which involves an update to SciPy. After this failed repeatedly due to wheel errors (more on this), I used SciPy to test what was going on, and found out this was failing to update, even when using "pip install -U SciPy"
Screenshots of errors below -- what is frustrating is that the log file it claims to generate in fact never is generated and there is not a folder or file where it claims to be and I have been through several iterations of tracking down, and in some cases having to create folders that were missing, updating 2017 build tools based on some of the errors that came up. That could be a whole other thread, but this is where it stands now when I try to update SciPy:
Screenshot of output part 1
Screenshot of output part 2
At this point I am immensely frustrated. What is the fix here? Will uninstalling all Python instances fix this? Or is there a deeper problem? I assumed the latter, but I have been installing things that seem to be missing and there's always something more. What the heck is going on? How can this be so screwed up on my machine and apparently unfixable?
Tried already:
pip install wheel
pip install meson
..and about a million iterations of installing other libraries or different flags on pip, no binary, update, etc. Python's not supposed to be this hard to set up, right? It wasn't before....
The issue looks like it's because you have 32 bit version of python installed and you are going from version 1.4.1 to 1.9.2.
SciPy v1.4.1 has a wheel (prebuilt binary) for 32 bit windows for python 3.8
SciPy v1.9.2 only has a wheel for 64bit windows python 3.8.
So when you installed it first (v1.4.1) everything was already compiled for you and it would have installed no problem.
As there is no wheel for v1.9.2 pip is attempting to build and compile everything from source (tar.gz file).
The SciPy docs say this is a nontrivial exercise but do provide steps https://scipy.github.io/devdocs/dev/contributor/building.html
You should be able to upgrade to v1.9.1 as this has wheel for python 3.8 32 bit.

(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Followed this guide (Cannot pip install mediapipe on Macos M1) to install Mediapipe on M1 mac, and now I am unable to use pandas or numpy.
ImportError: dlopen(/Users/matthewcuevas/Library/Python/3.8/lib/python/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 0x0002): tried: '/Users/matthewcuevas/Library/Python/3.8/lib/python/site-packages/pandas/_libs/interval.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
I got an error like this too. Solved it after a lot of trial & error.
The Problem: my brew was still running on Rosetta. Fixed that by uninstalling, cleaning and reinstalling. So everything seemed to run fine. Except this problem still kept cropping up
Until I discovered that pip is quite agressive in caching. So it caches the build even if the architecture changed. Solution: pip cache purge. Or remove the whole cache directory which you find with pip cache info
This will not be answer to your question/specific situation (most probably), but I got this issue when using python built for pyenv/virtualenv, and rm -rf ~/.pyenv helped me. So, python was reinstalled (properly this time; reinstalled by other scripts in our CI, because I deleted installation), and it's built for x86 and works fine on arm.
I solved by installing with conda instead of pip.
So, instead of
pip install pydantic==yourversion
Use:
conda install pydantic==yourversion.
Or, you can try installing with --no-binary (it saved me in a similar issue):
pip install pydantic==version --no-binary :all:
Go to Applications -> Xcode, then right click and select get info.
Then enable checbox "Open using Rosetta"
Finally close Xcode and open it and try again.

Installing a specific version of sklearn

I have been trying to run a example code which imports sklearn.When I tried to run it using the latest version I got the below error.
UserWarning: Trying to unpickle estimator pipeline from version 0.21.3
when using version 0.23.1. This might lead to breaking code or invalid
results. Use at your own risk.
And the program stops executing after this.
Many threads suggested that I should use the same version of sklearn which is 0.21.3.
So then I tried uninstalling sklearn and ran this command in my command line.
pip install sklearn==0.21.3
But then I got the error saying ,
Could not find a version that satisfies the requirement
What do I have to do in order to install sklearn 0.21.3 correctly using pip on windows?
Additional info : I am using python 3.7 on windows 10
As Alex stated, you need use to the full name of the module, uppercase is indifferent in this case. Both pip install scikit-learn==0.21.3 or pip install Scikit-learn==0.21.3 will work as I just tested it and I got a successful installation.

unable to find vcvarsall,bat error while installing simplecv on windows 10?

During the installation phase, I get this, "Unable to find vcvarsall.bat" error. The installation process did complete, though. However, I was unable to see the shell on my desktop (I am using windows) and neither was I able to open it manually. I scoured the internet for the error but was unable to find any solution for this case.
The installation process is through a superpack that downloads Python 2.7
SimpleCV is not receiving much love in the past few years, and most of it's code don't got upgrade like the libraries it depends on.
The problem you got is the Superpack trying to compile an older version of OpenCV.
When running the Superpack, you should have seen and redtext error, and if you try to run a code it should show you something like this:
File "C:\Python27\lib\site-packages\SimpleCV\base.py", line 59, in <module>
raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
ImportError: Cannot load OpenCV library which is required by SimpleCV
There are a few paths you can try from there:
1. You can try to install Microsoft Visual C++ Compiler for Python 2.7
Uninstall everything SuperPack installed in your PC or it may not work
It may fixes some other uses when using pip.
Now you have to install SimpleCV again.
2. Try to install OpenCV(2.3) on your own:
You can use pip for it, just remember to chose 32bits to keep compatibility with (Super Pack)
Just run on CMD
pip install OpenCV or python -m pip install OpenCV
3. Give up on SuperPack and install everything on your own.
You can try this guide
https://github.com/sightmachine/SimpleCV#windows-7vista
Or use pip for all dependencies
numpy (Numpy+MKL make sure to install this one first)
scipy
PIL
ipython
svgwrite
pygame==1.9.1release
OpenCV
You can find a useful list of wheels here
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
Sources:
https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
https://github.com/sightmachine/SimpleCV#windows-7vista

Why does installing numpy using pip fail, while building directly does not?

I'm trying to install numpy under Python 3.3.0 running Mac OS 10.7.5 (Lion) and using the compilers that come with Xcode 4.5.1. I installed Python 3 and gfortran using homebrew without any hiccups, but pip3 install numpy fails. Looking at other suggestions online, I tried setting Clang as the C compiler using:
export CC=clang
export CXX=clang
export FFLAGS=-ff2c
but received the same error. The final line reports ValueError: underlying buffer has been detached, and I posted the full output.
So, instead I tried building directly from source using the instructions from SciPy.org. This appears to succeed; the build and install processes run to completion, although they are not shy about reporting warnings. The full log is again available as a Gist. I can then run numpy.test('full') from Python 3, and although there are some warnings about unclosed files that I don't understand, it reports that all tests pass.
Does anyone know why pip fails to build NumPy when I can apparently do it manually without a problem?
It looks like numpy now provides wheels on pypi, which should install correctly without needing to compile anything locally on your machine when using pip.

Categories