How to install h5py (needed for Keras) on MacOS with M1? - python

I have an M1 MacBook. I have installed python 3.9.1 using pyenv, and have pip3 version 21.0.1.
I have installed homebrew and hdf5 1.12.0_1 via brew install hdf5.
When I type
pip3 install h5py
I get the error:
Requirement already satisfied: numpy>=1.19.3 in /Users/.../.pyenv/versions/3.9.1/lib/python3.9/site-packages (from h5py) (1.20.0)
Building wheels for collected packages: h5py
Building wheel for h5py (PEP 517) ... error
Loading library to get build settings and version: libhdf5.dylib
error: Unable to load dependency HDF5, make sure HDF5 is installed properly
error: dlopen(libhdf5.dylib, 6): image not found
----------------------------------------
ERROR: Failed building wheel for h5py
I saw that libhdf5.dylib is present in /opt/homebrew/opt/hdf5/lib, so I tried export LDFLAGS="-L/opt/homebrew/opt/hdf5/lib" and export CPPFLAGS="-L/opt/homebrew/opt/hdf5/include" beforehand but they don't help.
How can I install h5py?
I am actually installing h5py as a requirement to install Keras.
Thanks!

This works for me:
$ brew install hdf5
$ export HDF5_DIR="$(brew --prefix hdf5)"
$ pip install --no-binary=h5py h5py

Try to install h5py using conda. Works for me.
conda install h5py

Related

can't install scikit-learn in python 3.10 for Windows 10?

it's all about meson-python:
Run-time dependency openblas found: NO
....\scipy\meson.build:134:0: ERROR: Dependency "OpenBLAS" not
found
AttributeError: module 'mesonpy' has no attribute
'prepare_metadata_for_build_wheel'
here:
Platform Support - Windows :hammer: Does not support linking against
libraries from the Meson project
how to solve this problem on Windows 10 python 3.10 ?? in order to install scikit-learn
p.s. though developers say here:
Since version 0.21, scikit-learn automatically detects and uses the
linear algebra library used by SciPy at runtime. Scikit-learn has
therefore no build dependency on BLAS/LAPACK implementations such as
OpenBlas, Atlas, Blis or MKL
helped with Python-3.7, but NOT with Python-3.10
pip install numpy mkl
pip install scipy
pip uninstall scikit-learn
pip install --upgrade --force-reinstall --no-cache-dir scipy
pip install scikit-learn
SciPy should be installed first, then scikit-learn.
(still question in comments of initial Q - sorry to hurry with reply)
p.s.
in Python 3.10 still
ImportError: DLL load failed while importing qhull:
reason was while installing scikit-learn with
pip install --force-reinstall --prefer-binary scikit-learn
Preparing metadata (pyproject.toml): started Preparing metadata
(pyproject.toml): finished with status 'error'
exit code: 1
....
OSError: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
...
The Meson build system
Version: 1.0.0
.....
ERROR: Unhandled python OSError. This is probably not a Meson bug, but an issue with your build environment.
as I've understood, for my Win10 32x last stable version of Python is considered to be 3.7.(?3) to use scikit-learn
ok, the problem appeared to be in the localization of python installation -- reinstalled Python for all users (to Program Files folder), loaded WHEELS from here & installed for python-3.10:
pip install c:\numpy-1.22.4+mkl-cp310-cp310-win32.whl
pip install c:\scipy-1.7.3-cp310-cp310-win32.whl
pip install c:\scikit_learn-1.0.2-cp310-cp310-win32.whl
also pip install pandas-1.4.3-cp310-cp310-win32.whl
for python-3.7 needed numpy-1.21.6+mkl-cp37-cp37m-win32.whl
important: !! numpy + MKL (Math Kernel Library) is needed
CHECKED:
##pip install --upgrade --force-reinstall --no-cache-dir numpy==1.21.6
import numpy
print(numpy.version.version)
##pip install --force-reinstall c:\scipy-1.7.3-cp310-cp310-win32.whl
import scipy
print(scipy.version.version)
##--force-reinstall --no-cache-dir c:\scikit_learn-1.0.2-cp310-cp310-win32.whl
import sklearn as sk
print(sk.__version__)
RESULT:
1.22.4
1.7.3
1.0.2

pip install ecapture creates an error. How do I solve this?

I cannot install ecapture 0.1.8
Python version: 3.9.6
pip: 21.2.2
I am using Windows 10
I typed pip install ecapture
and got a whole bunch of collecting and installing messages, then this.:
ERROR: Failed building wheel for scikit-image
Failed to build scikit-image
ERROR: Could not build wheels for scikit-image which use PEP 517 and cannot be installed directly
I also tried installing scikit-image and wheel individually but that didn't work. Does anyone know how to help?
I used pip3 install ecapture --no-binary :all: and installed ecapture version 0.0.8 instead of 0.1.8
1 upload from https://pypi.org/project/ecapture/#files
2 download ecapture-0.1.8-py3-none-any.whl
3 open cmd go to download directory cd C:\Users\me\Downloads (in my PC)
4 pip install ecapture-0.1.8-py3-none-any.whl

How do I solve "incompatible numba" error while installing Scanpy?

I tried installing the Scanpy package on Jupyter with "pip install Scanpy" but I got the the errors below;
ERROR: pynndescent 0.5.2 has requirement numba>=0.51.2, but you'll have numba 0.48.0 which is incompatible. ERROR: umap-learn 0.5.1 has requirement numba>=0.49, but you'll have numba 0.48.0 which is incompatible
When I tried to separately install an upgraded version of numba, I got the error below;
ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Run pip install --upgrade numba
Run pip install scanpy
you can try install with pip install -c numba numba=0.51.2.1rc1 if it doesn't work for you alternativly install RUN pip install llvmlite --ignore installed before pip install numba.
HAVE A GOOD DAY:)

downgrading pip package in virtualenv

I set up a virtualenv and am trying to install a package where I get the error:
error: chardet 4.0.0 is installed but chardet<4.0,>=2.0 is required by {'aiohttp'}
Thus I tried to downgrade:
$ pip3 install --upgrade chardet==3.0.0
Collecting chardet==3.0.0
Using cached chardet-3.0.0-py2.py3-none-any.whl (133 kB)
Installing collected packages: chardet
Attempting uninstall: chardet
Found existing installation: chardet 4.0.0
Uninstalling chardet-4.0.0:
Successfully uninstalled chardet-4.0.0
Successfully installed chardet-3.0.0
Still when I try to install my package I get:
error: chardet 4.0.0 is installed but chardet<4.0,>=2.0 is required by {'aiohttp'}
I also tried to first uninstall the existing version:
pip3 uninstall chardet
But I still receive the error:
error: chardet 4.0.0 is installed but chardet<4.0,>=2.0 is required by {'aiohttp'}
Executing these steps I would expect chardet to downgrade to version 3.0.0 and my package to install. Is there a different way to do this without touching my packages outside of the venv?
Pipdeptree output:
$ pipdeptree
pipdeptree==2.0.0
- pip [required: >=6.0.0, installed: 21.0.1]
pkg-resources==0.0.0
setuptools==53.0.0
wheel==0.36.2
Edit:
downgrading indeed worked as expected. I got the error because the package I tried to install required sudo rights and thus by executing it as sudo I left the virtual environment. Downgrading the package globally let me install the package although I wanted to avoid this.
Try using pipdeptree, it displays installed packages as a dependency tree, there you can find a bug in chardet with different versions specified.

Circular dependency when installing numpy

I am trying to install numpy in my virtualenv but I face circular dependencies as follow:
(test) [hadoop#ip-192-168-26-8 test]$ python -m pip install numpy
Collecting numpy
Using cached https://files.pythonhosted.org/packages/62/20/4d43e141b5bc426ba38274933ef8e76e85c7adea2c321ecf9ebf7421cedf/numpy-1.18.1-cp36-cp36m-manylinux1_x86_64.whl
ERROR: tensorboard 2.1.0 requires grpcio>=1.24.3, which is not installed.
ERROR: tensorboard 2.1.0 requires markdown>=2.6.8, which is not installed.
ERROR: tensorboard 2.1.0 requires protobuf>=3.6.0, which is not installed.
ERROR: tensorboard 2.1.0 requires werkzeug>=0.11.15, which is not installed.
Installing collected packages: numpy
Successfully installed numpy-1.18.1
then when I try to install grpcio
(test) [hadoop#ip-192-168-26-8 test]$ python -m pip install grpcio
Collecting grpcio
Using cached https://files.pythonhosted.org/packages/17/8f/f79c5c174bebece41f824dd7b1ba98da45dc2d4c373b38ac6a7f6a5acb5e/grpcio-1.26.0-cp36-cp36m-manylinux2010_x86_64.whl
Requirement already satisfied: six>=1.5.2 in ./lib/python3.6/dist-packages (from grpcio) (1.14.0)
ERROR: tensorboard 2.1.0 requires markdown>=2.6.8, which is not installed.
ERROR: tensorboard 2.1.0 requires numpy>=1.12.0, which is not installed.
ERROR: tensorboard 2.1.0 requires protobuf>=3.6.0, which is not installed.
ERROR: tensorboard 2.1.0 requires werkzeug>=0.11.15, which is not installed.
Installing collected packages: grpcio
Successfully installed grpcio-1.26.0
I am not even sure why it gives me incorrect prompt Successfully installed grpcio-1.26.0, as they are not being added to my pip when I use list command.
Do you mind uninstalling numpy with below:
pip uninstall numpy
And install it again with --no-cache-dir option:
pip install numpy --no-cache-dir
Also, see that pip is upgraded.

Categories

Resources