pytables installation failed - installation

I do:
sudo pip install --upgrade tables
I get:
/usr/bin/ld: cannot find -lhdf5
collect2: ld returned 1 exit status
.. ERROR:: Could not find a local HDF5 installation.
You may need to explicitly state where your local HDF5 headers and
library can be found by setting the ``HDF5_DIR`` environment
variable or by using the ``--hdf5`` command-line option.
Complete output from command python setup.py egg_info:
/usr/bin/ld: cannot find -lhdf5
however:
$ echo $HDF5_DIR
/opt/hdf5/
$ ls /opt/hdf5/
bin include lib share
$ ls /opt/hdf5/lib/
libhdf5.a libhdf5_hl.la libhdf5_hl.so.8 libhdf5.la libhdf5.so libhdf5.so.8.0.1
libhdf5_hl.a libhdf5_hl.so libhdf5_hl.so.8.0.1 libhdf5.settings libhdf5.so.8
What's wrong? How to debug? I already tried to set HDF5_DIR to /opt/ or to /opt/hdf5/lib.

I also had the same error on Debian sid trying to work in a local virtualenv. To work around it I did:
apt-get build-dep python-tables
HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ && pip install tables
... now it's working.

I was able to fix this easily in OSX with virtual environments using the following code:
$ brew install hdf5
$ pyvenv test
$ workon myvenv # to get pytables working within the virtual environment myvenv
$ pip install numpy numexpr cython
$ pip install tables
(taken from andreabedini post in https://github.com/PyTables/PyTables/issues/385)

I'm having a similar problem, but I'm using the leading edge not the pip release (see Aside).
I also tried pointing to the library itself
export HDF5_DIR=/usr/lib/libhdf5.so.6
but it did not work.
Aside: You can try the leading edge of PyTables if you think your bug may have been addressed recently:
sudo pip install git+https://github.com/PyTables/PyTables
.
The build (that was caused by pip install...) seemed to progress further after I installed the dev version of the hdf5 library (libhdf5-openmpi-dev). The build still failed for other reasons, but it's another direction you could try.

Perhaps you can install the stable wheel file for your os for pytables from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pytables
Use this command to check for which file to download
path/to/pythonX.Y -m pip debug --verbose
And this command to install the wheel file
pip install C:/some-dir/some-file.whl

I tried everything without success. The only way I could I achieved was using nehalecky's answer I got here:
https://github.com/PyTables/PyTables/issues/219
In a nutshell, you should do these 2 commands, correcting the path, of course:
sudo python3 setup.py build_ext --inplace --hdf5=/usr/lib/x86_64-linux-gnu/hdf5/serial/
sudo python3 setup.py install --hdf5=/usr/lib/x86_64-linux-gnu/hdf5/serial/
Hope it helps!

Related

An issue with installation of ansible-pylibssh on Apple Silicon M2

I've got an issue with installation of ansible-pylibssh.
During installation
pip3 install --user ansible-pylibssh
I got
ld: library not found for -lssh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1
Could someone explain how to overcome this?
I've already done softlink
% cd /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
% sudo ln -s /opt/homebrew/Cellar/libssh/0.10.4/include/libssh/ libssh
Install libssh:
brew install libssh
Use a python virtual environment :
python3 -m venv .venv
source .venv/bin/activate
EDIT:
Install with correct compiler flags:
CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh" pip install ansible-pylibssh
Thanks, #webknjaz!
OLD Additional steps not needed (preserved for history):
Install tox build tool:
pip install 'tox >= 3.19.0'
Build from source on ARM-based Macs, per the ansible-pylibssh docs:
#git clone https://github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
# or, if you use SSH:
git clone ssh://git#github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
cd ~/src/github/ansible/pylibssh
Use libraries installed by brew with clang:
export CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh"
Build ansible-pylibssh:
tox -e build-dists
Install built ansible-pylibssh wheel:
pip install ~/src/github/ansible/pylibssh/dist/ansible_pylibssh*.whl
Additional resources that lead to this answer:
Kristof Rado's answer to Cannot install ansible-pylibssh on macOS
ansible/pylibssh GitHub issue 207 provides background on why this package is not available for macOS on ARM from PyPi (symlink/softlink to point to the libraries did not help. Correct compiler flags were the needed answer.)
If you prefer not to work with a virtual environment, this may work: replace pip commands python3 -m pip --user and python commands with python3.

Unable to install PyAudio on M1 Mac [PortAudio already installed]

I have visited many forums, tried diffrent methods like brew, pip, port and many more but still am facing the same error.
View this Image for more detail
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
Can anyone help?
These steps worked on M1 Pro chips
Install portaudio
brew install portaudio
Link portaudio
brew link portaudio
Copy the path where portaudio was installed (use it in the next step)
brew --prefix portaudio
Create .pydistutils.cfg in your home directory
sudo nano $HOME/.pydistutils.cfg
then paste the following
[build_ext]
include_dirs=<PATH FROM STEP 3>/include/
library_dirs=<PATH FROM STEP 3>/lib/
Install pyaudio
pip install pyaudio
or
pip3 install pyaudio
For me it was:
brew install portaudio
python -m pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
This Solution is tested on M1 Macs[Please do check with other].
After the installation of HomeBrew on your system, perform the installation of PortAudio. Next follow the steps mentioned below:
Use the command to install PortAudio
sudo brew install portaudio
After successful installation of PortAudio, enter the following command.
sudo nano $HOME/.pydistutils.cfg
Next, enter the following lines in the opened window
[build_ext]
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/include/
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/lib/
Note: PortAudio location may be different for you and also don't forget to replace your PC username.
Finally run the command
pip install pyaudio
or
pip3 install pyaudio
The main challenge we're encountering here is that pyaudio doesn't know where to find the portaudio libraries since, according to the source, it only looks in these locations for darwin platform installations:
include_dirs += ['/usr/local/include', '/usr/include']
external_libraries_path += ['/usr/local/lib', '/usr/lib']
This won't do if you're using a homebrew installation of portaudio, particularly so with Apple Silicon since there isn't a pre-built wheel in PyPi. This means setuptools/pip will need to build the package from source.
There are a few ways of configuring setuptools to use additional paths, including passing arguments, using a .pydistutils.cfg file, among others, but the second option worked for me given I'm installing pyaudio to a few Python environments.
Building off of some of the answers above, you can copy the following below to install pyaudio in one go.
# Install portaudio, will print list of paths where it's been installed if already done
brew list portaudio || brew install portaudio
# Link portaudio, will print a warning if already linked
brew link portaudio
# Create a pydistutils config file with the portaudio lib paths set correctly (no copying/pasting paths required)
cat <<EOF >> .pydistutils.cfg
[build_ext]
include_dirs=`brew --prefix portaudio`/include/
library_dirs=`brew --prefix portaudio`/lib/
EOF
# install (build) package with pip
python -m pip install pyaudio
All we're doing is telling setuptools to also look for C/C++ headers where portaudio has been installed by homebrew.
vkshah has an error in his second line. It should ready library_dirs instead of include_dirs:
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/include/
library_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/lib/```
For me, I am running Big Sur on an M1 Mac. I followed all the instructions mentioned in other threads to:
install portaudio
arch -arm64 brew install portaudio
start a venv
python3 -m venv env
source env/bin/activate
install pyaudio
arch -arm64 pip install --no-cache-dir --global-option='build_ext' --global-option='-I/opt/homebrew/include' --global-option='-L/opt/homebrew/lib' pyaudio==0.2.11
TIP #1
If you see error on portaudio.h file not found, the solution is specifying the pyaudio version at the end. Because it kept trying to install version '0.2.12' which failed. I specify the version of pyaudio to '0.2.11' (see above).
TIP #2
After successfully installing pyaudio, you may see error PyAudio C module _portaudio, that is due to pip built it(_portaudio.cpython-36m-darwin.so) in x86_64 architecture. It's not compatible with arm64 portaudio, in this case, make sure to include arch -arm64 in front of pip to build the correct binary.
TIP #3
Use an older version of python, I personally used version 3.6.
Oh, and make sure the single quote is actually ' if you copied the command from a text editor.
Hope this helps!
first you need to download portaudio using homebrew
brew install portaudio
Then try to install pyaudio directly
pip install pyaudio
if you are getting error while installing follow below step
Or
if you are facing any error mentioned bellow you can follow these steps
error 1
option 'include_dirs' in section 'build_ext' already exists
error 2
Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
error 3
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
solution start here
after installing homebrew you have to link it
brew link portaudio
in some cases it will say that it has been already linked then simply ignore
we need path of portaudio where it is exactly installed
brew --prefix portaudio
it will gives you path of portaudio
then you have to check if pydistutils.cfg file exists or not
sudo cat $HOME/.pydistutils.cfg
if file exists then it will open else create it will below command
sudo cat $HOME/.pydistutils.cfg
so in these file we have to define proper path here
[build_ext]
include_dirs=/--PATH--/include/
library_dirs=/--PATH--/lib/
you can get that path by running below command
brew --prefix portaudio
if that path is not working then try below path
[build_ext]
include_dirs=/Users/<username>/homebrew/Cellar/portaudio/19.20140130/include/
library_dirs=/Users/<username>/homebrew/Cellar/portaudio/19.20140130/lib/
If you use mac os
Install Homebrew (insert link into the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" )
Insert command into the terminal:
brew install portaudio
Insert command into the terminal:
pip install pyaudio
p.s. sometimes you need upgrade your pip installer
These actions solved my problem (mac os Mojave 10.14.4)

RuntimeError: <path> failed executing, please point LLVM_CONFIG to the path for llvm-config

Trying to install llvmlite via pip by running
pip install llvmlite
constantly gives me this error:
RuntimeError: <path> failed executing, please point LLVM_CONFIG to the path for llvm-config
error: command '/Users/sfalk/miniconda3/envs/asr-service/bin/python' failed with exit status 1
----------------------------------------
Now, I am on Python 3.5
$ python --version
Python 3.5.6 :: Anaconda, Inc.
And just running pip install llvmlite will give me this:
RuntimeError: Building llvmlite requires LLVM 7.0.x, 7.1.x or 8.0.x, got '10.0.0'. Be sure to set LLVM_CONFIG to the right executable path.
I installed LLVM 8 via brew
brew install llvm#8
Setting LLVM_CONFIG to either does not work.
/usr/local/opt/llvm#8/bin (were I assumed llvm-config to be), or
/usr/local/opt/llvm#8/Toolchains/LLVM8.0.1.xctoolchain/usr/bin (where I actually found llvm-config to be)
And I keep getting some version of:
RuntimeError: /usr/local/opt/llvm#8/Toolchains/LLVM8.0.1.xctoolchain/usr/bin failed executing, please point LLVM_CONFIG to the path for llvm-config
What am I missing here?
And for those reviewing the post in search for a solution to installing numba, the version released on June 24, 2020 works:
pip install numba==0.50.1
Looks like there is an issue with latest version of llvmlite. Please consider using 0.31.0 version.
>>pip install llvmlite==0.31.0
Collecting llvmlite==0.31.0
Downloading
https://files.pythonhosted.org/packages/10/31/aa315fbc2e0b7777b95ce166b7c988f53e4cdd4c33d06eea24f395539eb4/llvmlite-0.31.0-cp35-cp35m-macosx_10_9_x86_64.whl (15.9MB)
100% |████████████████████████████████| 15.9MB 1.1MB/s
Installing collected packages: llvmlite
Successfully installed llvmlite-0.31.0
You will have to install the required llvm package using and link the executable config
sudo apt install llvm-**X**
and then
sudo pip3 install llvmlite
cd /usr/bin
sudo ln -s llvm-config-**X** llvm-config
This fixed the llvm issue of installing librosa on my raspberry pi (aarch64)
I was facing the same issue.
You will have to install the required llvm package using and link the executable config
sudo apt install llvm-X
and then
sudo pip3 install llvmlite
cd /usr/bin
sudo ln -s llvm-config-X llvm-config
did not work for me but I did notice we had the same output error
RuntimeError: <path> failed executing, please point LLVM_CONFIG to the path for llvm-config
So I thought: "why not point the LLVM_CONFIG to the proper llvm-config?".
And I did this simple fix:
export LLVM_CONFIG=/usr/bin/llvm-config-10

Error installing PyGObject, 'glib-object.h' file not found

I am trying to install pygobject for python 2.7 in pycharm for the purpose of using gstreamer. However I am having problems installing it. While in the virtual environment, if I use
pip install pygobject
Then the build fails and gives me this error
gi/gimodule.c:25:10: fatal error: 'glib-object.h' file not found
#include <glib-object.h>
^~~~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
full error log here
I know for a fact that glib exists on my system from searching for it with
find /usr -name glib-object.h
but for some reason the install can't find it. Do I have to link it in somehow/how do I go about doing this?
Also I know I can more successfully use this library with python3 but that caused some weird system errors that can apparently be resolved by using 2.7 so I am just exploring that at the moment.
With virtual environments it's recommended installing PyGObject with pipenv instead of pip.
Install pipenv with either MacPorts, HomeBrew or pipsi:
MacPorts
port install pipenv
HomeBrew
brew install pipenv
pipsi
curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3 - --src=git+https://github.com/mitsuhiko/pipsi.git\#egg=pipsi
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
pipsi install pew
pipsi install pipenv
Once you've got pipenv installed then you should be able to add the package to your virtual environment:
pipenv install pygobject
↳ PyGObject : Creating A Development Environment

Install OpenCV on Mac - VirtualEnv (Updated bash_profile and pip error)

I'm trying to install OpenCV on my Mac (OS X 10.11.3) using this tutorial because it uses a VirtualEnv, which is a way to ensure consistency in development.
I skipped Steps 1&2 since I already have Xcode and Homebrew. Step 3 worked well (after updating ~/.bash_profile as instructed):
User:~ user$ brew update
Already up-to-date.
User:~ user$ source ~/.bash_profile
User:~ user$ which python
/usr/local/bin/python
User:~ user$
The trouble is in Step 4:
User:~ user$ pip install virtualenv virtualenvwrapper
-bash: /usr/local/bin/pip: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
User:~ user$
This is probably because I'm in the local bin due to adding this to ~/.bash_profile from Step 3:
# Homebrew
export PATH=/usr/local/bin:$PATH
This basically means I can't access pip from that location, but when I try to install it locally (with the above lines added in ~/.bash_profile), it says:
User:~ user$ brew install pip
Error: No available formula with the name "pip"
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.org/en/stable/installing/#install-pip
User:~ user$
How can I access pip with my updated ~/.bash_profile from Step 3? Thanks!
Ok, I figured out the problem.
I was getting the same errors as this stackoverflow question, so I ran the recommended
brew link python
which encountered the same errors as this stackoverflow question, so I ran the recommended
brew link --overwrite python
which seemed to correct the problem and allows me to run pip while accessing Homebrew packages first.

Resources