For python, install hdf5/netcdf4 - python

Doing this on a Linux Mint 17.1.
When I try:
pip install hdf5
I get the error
"Could not find a version that satisfies the requirement hdf5 (from versions: )
No matching distribution found for hdf5"
I'm trying in the long run to install netcdf4 but can't do that until I get hdf5 installed. Supposedly from when I was trying to do this last week, with netcdf4, I should be using the pip install netcdf4, err hdf5...at least maybe in the case of hdf5.
If I try pip install h5py I get that the message saying:
Requirement already satisfied (use --upgrade to upgrade): h5py in ./anaconda3/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in ./anaconda3/lib/python3.5/site-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): six in ./anaconda3/lib/python3.5/site-packages (from h5py)
Yet if I go ahead and try pip install netcdf4 it comes up and says:
Collecting netcdf4
Using cached netCDF4-1.2.3.1.tar.gz
Complete output from command python setup.py egg_info:
Package hdf5 was not found in the pkg-config search path.
Perhaps you should add the directory containinghdf5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'hdf5' found
cython version 0.23.4 found ...
reading from setup.cfg...
HDF5_DIR environment variable not set, checking some standard locations ..
checking /home/meant2b ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-pq3yt4ek/netcdf4/setup.py", line 286, in <module>
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-pq3yt4ek/netcdf4/`
When I search the files I don't find a hdf5.pc file.
Is there a difference between h5py and hdf5? Do I have to compile and install hdf5 from the individual files or can I pip install.
What do I have to do to be able to install both hdf5 and netcdf4?

You need to install the HDF5 libraries for your Linux distribution. In Ubuntu is:
sudo apt-get install libhdf5-serial-dev netcdf-bin libnetcdf-dev
See this link.

I had the same issue in Debian 8. To fix it, as root, I installed the libraries, then linked the serial headers to a include dir inside the hdf5 libraries, exported the HDF_DIR path and installed netCDF4:
# apt-get install -y libhdf5-dev libnetcdf-dev
# ln -s /usr/include/hdf5/serial /usr/include/hdf5/include
# export HDF5_DIR=/usr/include/hdf5
# pip install netCDF4

I had the same error under macOS Catalina. Had to install the hdf5 and netcdf4 packages from Homebrew:
brew install hdf5 netcdf4
Afterwards, pip3 install netcdf4 worked fine.

Related

module on test.pypi can't install dependencies, even though they exist [duplicate]

This question already has answers here:
Pip install from pypi works, but from testpypi fails (cannot find requirements)
(2 answers)
Closed 2 years ago.
I have done this small package that I want to distribute in my community. It is now on test.pypi and when I want to try to install it, it gives an error that dependencies couldn't be found.
setup.py
...
install_requires=[
'defcon>=0.6.0',
'fonttools>=3.31.0'
]
...
throws this error
ERROR: Could not find a version that satisfies the requirement defcon>=0.6.0 (from sameWidther==0.6) (from versions: none)
ERROR: No matching distribution found for defcon>=0.6.0 (from sameWidther==0.6)
but when I manually install, it works
pip install 'fonttools>=3.6.0'
pip install 'defcon>=0.6.0'
-i URL, or --index-url URL means "use URL for installing packages from exclusively". By passing -i https://test.pypi.org/simple/, you thus prohibit searching and downloading packages from PyPI (https://pypi.org/simple). To use both indexes, use --extra-index-url:
$ python -m pip install --extra-index-url https://test.pypi.org/simple/ sameWidther

No matching distribution found

I am trying to collect all the wheel files for libffi-dev. Trying the command mentioned below:
pip wheel --wheel-dir=setup libffi-dev
is giving
Collecting libffi-dev
Could not find a version that satisfies the requirement libffi-dev (from versions: )
No matching distribution found for libffi-dev
Thanks in advance :)
libffi-dev is the name of the Ubuntu package. cffi is the one from PyPI. You need to install both:
sudo apt-get install libffi-dev
pip install cffi
If you are trying to install wordcloud and facing this issue.
From https://pypi.org/simple/wordcloud/ download the corresponding .whl file for the Python version and OS you are using. (I have downloaded wordcloud-1.5.0-cp37-cp37m-win_amd64.whl meant for 64 bit windows).
Place the file in C:\Users\<User>
From command prompt run
pip install --verbose --trusted-host files.pythonhosted.org wordcloud-1.5.0-cp37-cp37m-win_amd64.whl
This worked for me. Found this solution after a lot of research.
C:\Users\**<user>**>pip install --verbose --trusted-host files.pythonhosted.org wordcloud-1.5.0-cp37-cp37m-win_amd64.whl
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Created temporary directory: C:\Users\<user>\AppData\Local\Temp\pip-ephem-wheel-cache-hqkva4rs
Created temporary directory: C:\Users\<user>\AppData\Local\Temp\pip-req-tracker-0cimhb2c
Created requirements tracker 'C:\\Users\\<user>\\AppData\\Local\\Temp\\pip-req-tracker-0cimhb2c'
Created temporary directory: C:\Users\<user>\AppData\Local\Temp\pip-install-y5b3ck8i
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Processing c:\users\<user>\wordcloud-1.5.0-cp37-cp37m-win_amd64.whl
Added wordcloud==1.5.0 from file:///C:/Users/<user>/wordcloud-1.5.0-cp37-cp37m-win_amd64.whl to build tracker 'C:\\Users\\<user>\\AppData\\Local\\Temp\\pip-req-tracker-0cimhb2c'
Removed wordcloud==1.5.0 from file:///C:/Users/<user>/wordcloud-1.5.0-cp37-cp37m-win_amd64.whl from build tracker 'C:\\Users\\<user>\\AppData\\Local\\Temp\\pip-req-tracker-0cimhb2c'
Requirement already satisfied: pillow in c:\users\<user>\anaconda3\lib\site-packages (from wordcloud==1.5.0) (5.4.1)
Requirement already satisfied: numpy>=1.6.1 in c:\users\<user>\anaconda3\lib\site-packages (from wordcloud==1.5.0) (1.15.1)
Installing collected packages: wordcloud
Successfully installed wordcloud-1.5.0
Cleaning up...
Removed build tracker 'C:\\Users\\<user>\\AppData\\Local\\Temp\\pip-req-tracker-0cimhb2c'

Installing Python packages from local file system folder with pip

I am trying to install python packages from the local file system with pip as discussed in this question.
I have used pip2pi as suggested in the accepted answer in the above question.
dmanna#ubuntu:~$ mkdir -p pyt/pkg
dmanna#ubuntu:~$ pip2tgz pyt/pkg/ patroni[zookeeper]
The downloaded packages
dmanna#ubuntu:~$ ls /home/dmanna/pyt/pkg/
cdiff-1.0.tar.gz
certifi-2018.4.16-py2.py3-none-any.whl
chardet-3.0.4-py2.py3-none-any.whl
click-6.7-py2.py3-none-any.whl
idna-2.7-py2.py3-none-any.whl
kazoo-2.5.0-py2.py3-none-any.whl
patroni-1.4.4.tar.gz
prettytable-0.7.2.tar.bz2
psutil-5.4.6.tar.gz
psycopg2-2.7.4.tar.gz
python_dateutil-2.7.3-py2.py3-none-any.whl
pytz-2018.4-py2.py3-none-any.whl
PyYAML-3.12.tar.gz
requests-2.19.1-py2.py3-none-any.whl
six-1.11.0-py2.py3-none-any.whl
tzlocal-1.5.1.tar.gz
urllib3-1.23-py2.py3-none-any.whl
Then when I am trying to install the required package from the above local directory. It is giving me the below error
dmanna#ubuntu:~$ sudo pip install --no-index --find-links=pyt/pkg/patroni-1.4.4.tar.gz patroni[zookeeper]
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking patroni[zookeeper]
Running setup.py (path:/tmp/pip_build_root/patroni/setup.py) egg_info for package patroni
Installing extra requirements: 'zookeeper'
Downloading/unpacking urllib3>=1.19.1,!=1.21 (from patroni[zookeeper])
Could not find any downloads that satisfy the requirement urllib3>=1.19.1,!=1.21 (from patroni[zookeeper])
Cleaning up...
No distributions at all found for urllib3>=1.19.1,!=1.21 (from patroni[zookeeper])
Storing debug log for failure in /home/dmanna/.pip/pip.log
Can someone let me know what I am doing wrong?
Python - 2.7.6
PIP - 1.5.4
Ubuntu 14.04
--find-links=pyt/pkg
Find links in the directory, not in the patroni-1.4.4.tar.gz archive.

Installing gmpy2 on windows using pre-compiled binaries

I am trying to install the gmpy2 package as its an requirement for the PHE package. As suggested in "GMPY2 not installing", I have tried to install it via pre-compliled binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
However when I try to install it via
pip install gmpy2-2.0.8-cp36-cp36m-win32.whl
I get the following result:
C:\Users\adria\Desktop>pip install gmpy2-2.0.8-cp36-cp36m-win32.whl
Requirement 'gmpy2-2.0.8-cp36-cp36m-win32.whl' looks like a filename, but the file does not exist
Processing c:\users\adria\desktop\gmpy2-2.0.8-cp36-cp36m-win32.whl
Exception:
Traceback (most recent call last): (...)
Is it a problem that the download from http://www.lfd.uci.edu/~gohlke/pythonlibs/ is saved as zip file?
I use Python 3.6.3 on Win10.
If you try to install without specifying the file extension (i,e : pip install gmpy2-2.0.8-cp36-cp36m-win_amd64) it won't work cause it will try to download the package from pypi repository:
C:\Users\bobolafrite\Downloads>pip install gmpy2-2.0.8-cp36-cp36m-win_amd64
Collecting gmpy2-2.0.8-cp36-cp36m-win_amd64
Could not find a version that satisfies the requirement gmpy2-2.0.8-cp36-cp36m-win_amd64 (from versions: )
No matching distribution found for gmpy2-2.0.8-cp36-cp36m-win_amd64
But if you try with the extension (i,e : pip install gmpy2-2.0.8-cp36-cp36m-win_amd64.whl)
C:\Users\bobolafrite\Downloads>pip install gmpy2-2.0.8-cp36-cp36m-win_amd64.whl
Processing c:\users\bobolafrite\downloads\gmpy2-2.0.8-cp36-cp36m-win_amd64.whl
Installing collected packages: gmpy2
Successfully installed gmpy2-2.0.8

Lightgbm OSError, Library not loaded

If I simply do:
import lightgbm as lgb
I'm getting
python script.py
Traceback (most recent call last):
File "script.py", line 4, in <module>
import lightgbm as lgb
File "/usr/local/lib/python2.7/site-packages/lightgbm/__init__.py", line 8, in <module>
from .basic import Booster, Dataset
File "/usr/local/lib/python2.7/site-packages/lightgbm/basic.py", line 31, in <module>
_LIB = _load_lib()
File "/usr/local/lib/python2.7/site-packages/lightgbm/basic.py", line 26, in _load_lib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/7/libgomp.1.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so
Reason: image not found
I seem to have everything installed correct:
python -m pip install lightgbm
Requirement already satisfied: lightgbm in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: wheel in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: scikit-learn in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: scipy in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/site-packages (from lightgbm)
I do have a 6 folder in my GCC folder. Should I need to install another version of GCC for this to work?
All the above answers didn't work for me.
On Mac, if I installed the libomp using brew fixed the problem: Refer: link
brew install libomp
I find a similar problem here LightGBM
The answer and comment may help you.
Build LightGBM in Mac:
brew install cmake
brew install gcc --without-multilib
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
mkdir build ; cd build
cmake ..
make -j
Then install:
cd ../python-packages
sudo python setup.py install --precompile
As stated by #ecodan, you might need to force Mac to use GCC and G++ instead of the default compiler. So instead of building with cmake .., try:
cmake -DCMAKE_C_COMPILER=/usr/local/Cellar/gcc/6.1.0/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/local/Cellar/gcc/6.1.0/bin/g++-6 ..
ajusting the versions to match yours.
I had the same exact problem on M1 MAC. I have tried to import it through Jupiter notebook. This command solved the problem:
conda install lightgbm
On MAC you need to install open-mpi:
brew install open-mpi
Same error, different source: seems like I had the gcc 8 version installed, and it needs gcc 7.
It worked by switching it back to last gcc 7 version:
brew switch gcc 7.3.0_1
For users with macports, replace the beginning of the brew solution with:
port install gcc7 cmake
export CXX=g++-mp-7 CC=gcc-mp-7
On MacOS High Sierra with MacPorts installed, I did the following:
Install clang-5.0 using MacPorts
Inside the /build directory, run
cmake -DCMAKE_CXX_COMPILER=clang++-mp-5.0 -DCMAKE_C_COMPILER=clang-mp-5.0 ..
To build the python package, go to /python_package directory and modify the setup.py script.
You need to modify the function compile_cpp() at the very end that checks the case for other OS (including Mac). Before the silent_call(...), add the following two lines:
cmake_cmd.append("-DCMAKE_CXX_COMPILER=clang++-mp-5.0")
cmake_cmd.append("-DCMAKE_C_COMPILER=clang-mp-5.0")
Run sudo python setup.py install. Enjoy
I used this command generated from PyCharm and it worked for me.
conda install -p { < =replace with USER_HOME_DIR>}/anaconda3 lightgbm -y
Note : i tried Brew and pip install but they didn't work for me as Azure ML studio already downloaded other versions of LightGBM that were causing conflict in upgrading to correct packages.
conda install -c conda-forge lightgbm

Categories