"hdf5.h" not found when installing Neon - python

I'm trying to install Neon, a machine learning package (http://neon.nervanasys.com/docs/latest/installation.html), after cloning the Github repository, cd'ing to the neon directory, and running the make command I am running into the following error:
^
In file included from /tmp/pip-build-2yDIC3/h5py/h5py/defs.c:279:0:
/tmp/pip-build-2yDIC3/h5py/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/kurt/Documents/Python/neon/.venv2/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2yDIC3/h5py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ArslBc-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kurt/Documents/Python/neon/.venv2/include/site/python2.7/h5py" failed with error code 1 in /tmp/pip-build-2yDIC3/h5py/
Makefile:115: recipe for target '.venv2/bin/activate' failed
make: *** [.venv2/bin/activate] Error 1
The error seems to be associated with h5py, which is a requirement. However, that appears to have been installed correctly:
kurt#kurt-ThinkPad:~$ sudo pip install h5py
The directory '/home/kurt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kurt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): h5py in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /usr/local/lib/python2.7/dist-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from h5py)
I've also tried setting hard links to the "serial" postfixes of the lib names of hdf5, as described in https://github.com/NVIDIA/DIGITS/issues/156, but to no avail. Curiously, if I run the make command again, I don't get the same error message but the following:
kurt#kurt-ThinkPad:~/Documents/Python/neon$ make
make[1]: Entering directory '/home/kurt/Documents/Python/neon/loader'
Building bin/loader.so...
g++ -shared -o bin/loader.so -fPIC -Wall -Wno-deprecated-declarations -O3 -std=c++11 -DHAS_IMGLIB -DHAS_VIDLIB -DHAS_AUDLIB src/loader.cpp -I/usr/include/opencv -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lavutil -lavformat -lavcodec -lswscale
make[1]: Leaving directory '/home/kurt/Documents/Python/neon/loader'
It says "Leaving directory" without an explicit error message, but when I try to import neon modules I get ImportError: No module named neon... errors.
Any ideas on how to fix this?

Following Evert's suggestion (and reading the instructions more carefully), I installed libhdf5-dev from a .deb file from http://packages.ubuntu.com/trusty/amd64/libhdf5-dev/download. After this neon worked. (It has to be run from a virtual environment).

Related

Docker build python app error "No matching distribution found for spacy==2.3.2" on Apple M1

I recently switched to a Mac mini M1, and am trying to run a project that was running ok in my old intel MBP. Because the project uses node#10, I switched to using Rosetta2, but even with Rosetta2, one of the docker builds still errors.
The failing Dockerfile (omitted some lines for brevity)
FROM python:3.8
ADD requirements.txt /
RUN pip install -r requirements.txt
requirements.txt (omitted some packages/lines that I thought were unrelated)
blis==0.4.1
spacy==2.3.2
When trying to build this with docker-compose, I get (omitted some stack-trace & formatted for readability):
ERROR: Command errored out with exit status 1:
/usr/local/bin/python -u -c 'import sys, setuptools, tokenize;
sys.argv[0] = '"'"'/tmp/pip-install-a0pf23u9/blis_b27be89cc1164feb9077684e8666c831/setup.py'"'"';
__file__='"'"'/tmp/pip-install-a0pf23u9/blis_b27be89cc1164feb9077684e8666c831/setup.py'"'"';
f=getattr(tokenize, '"'"'open'"'"', open)(__file__);
code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');
f.close();
exec(compile(code, __file__, '"'"'exec'"'"'))' install
--record /tmp/pip-record-5h72yjx8/install-record.txt
--single-version-externally-managed
--prefix /tmp/pip-build-env-84ng6en9/overlay
--compile
--install-headers /tmp/pip-build-env-84ng6en9/overlay/include/python3.8/blis
Check the logs for full command output.
#9 113.4 WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
#9 113.4 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
#9 113.4 ----------------------------------------
#9 113.4 WARNING:
Discarding https://files.pythonhosted.org/packages/18/db/499f374339b522b6618234b93f25d2990692795ccce3152519ccc508586c/spacy-2.3.2.tar.gz#sha256=818de26e0e383f64ccbe3db185574920de05923d8deac8bbb12113b9e33cee1f
(from https://pypi.org/simple/spacy/) (requires-python:!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7).
Command errored out with exit status 1:
/usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install
--ignore-installed
--no-user
--prefix /tmp/pip-build-env-84ng6en9/overlay
--no-warn-script-location
--no-binary :none:
--only-binary :none:
-i https://pypi.org/simple
-- setuptools wheel 'cython>=0.25' 'cymem>=2.0.2,<2.1.0' 'preshed>=3.0.2,<3.1.0' 'murmurhash>=0.28.0,<1.1.0' thinc==7.4.1
Check the logs for full command output.
#9 113.4 ERROR: Could not find a version that satisfies the requirement spacy==2.3.2
#9 113.4 ERROR: No matching distribution found for spacy==2.3.2
Before the Run pip install ... line, I tried adding:
RUN pip install pip --upgrade, failed,
RUN pip install wheel, failed,
RUN pip install spacy==2.3.2 --no-cache-dir (commented out spacy in requirements.txt), failed,
all of the above at the same time, failed.
Any idea what could be wrong, or what the solution may be here?
UPDATE:
Tried to build the above Dockerfile (initial version) in a terminal using arm64, but still get the same error.
UPDATE 2:
Tried bumping (minor) blis & spacy packages, still fails with the same error.
As a last resort, I bumped all the packages in the requirements file to their latest versions, and now it builds successfully.

Error while trying to do download pygame on python3.8 arch linux

So while i try to download pygame using pip3 i get an error. I try Multiple ways
sudo apt install python3-pygame
sudo apt-get install python3-pygame
sudo pip3 install pygame
I try doing all of these but on the pip installation
it gives me this error.
jorge#raspberrypi:~$ python3 -m pip install -U pygame --user
Collecting pygame
Downloading pygame-1.9.6.tar.gz (3.2 MB)
|████████████████████████████████| 3.2 MB 1.7 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t3uuppky/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t3uuppky/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-t3uuppky/pygame/pip-egg-info
cwd: /tmp/pip-install-t3uuppky/pygame/
Complete output (29 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
/bin/sh: 1: freetype-config: not found
/bin/sh: 1: freetype-config: not found
/bin/sh: 1: freetype-config: not found
Hunting dependencies...
WARNING: "sdl-config" failed!
WARNING: "pkg-config freetype2" failed!
WARNING: "freetype-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
On archlinux, you can do a simple
$ sudo pacman -S python-pygame
and it will install pygame and all of its dependencies. What I see from your error is than the dependency freetype2 is not present on your machine. The above command will probably install it as a dependency probably, but it does not matter since it is all managed by pacman.

Cannot pip install package in virtualenv on EC2

I'm seeing this weird issue on ec2. I'm trying to install lsm-db package inside my virtualenv, it says it's successfully installed but when trying to import the package or do pip list it's not there.
I created this virtualenv by
virtualenv -p python3.6 venv
source venv/bin/activate
then running which python and which pip shows the correct ones inside venv as <path-to-my-project>/venv/bin/pip. Then I run pip install -r requirements.txt where sqlalchemy and lsm-db are included. A warning is shown
WARNING: Building wheel for lsm-db failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
WARNING: Building wheel for sqlalchemy failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
Failed to build lsm-db sqlalchemy
Installing collected packages: sqlalchemy, flask-sqlalchemy, lsm-db, MarkupSafe, click
Running setup.py install for sqlalchemy ... done
Running setup.py install for lsm-db ... done
Successfully installed MarkupSafe-1.1.1 click-7.0 flask-sqlalchemy-2.4.0 lsm-db-0.6.4 sqlalchemy-1.3.5
The last line shows they are correctly installed despite the warnings. However, they are not. Running pip install lsm-db gives
▶ pip install lsm-db
WARNING: The directory '/home/ec2-user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/ec2-user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lsm-db
Downloading https://files.pythonhosted.org/packages/17/f2/dc68ecdece424eb206c42b8db924c5a7f6dd97d26df42a1c9fb41a6fe555/lsm-db-0.6.4.tar.gz (316kB)
|████████████████████████████████| 317kB 14.7MB/s
Building wheels for collected packages: lsm-db
WARNING: Building wheel for lsm-db failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
Failed to build lsm-db
Installing collected packages: lsm-db
Running setup.py install for lsm-db ... done
Successfully installed lsm-db-0.6.4
Again it shows it's installed, but it's not. Not in pip list, can't import in Python. What is going on here? Why do I see permission issue inside virtualenv? I didn't create the virtualenv with sudo if that's a potential problem. Is it related to the way I installed virtualenv?
EDIT
I changed the permission and reinstall pip with sudo yum install python36-pip. Now I'm seeing this... sorry it seems like a new problem
Running setup.py install for lsm-db ... error
ERROR: Complete output from command /home/ec2-user/<project>/venv/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bhhmd3j8/lsm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-__gotpo6/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/<project>/venv/include/site/python3.6/lsm-db:
ERROR: /tmp/pip-install-bhhmd3j8/lsm-db/setup.py:11: UserWarning: Cython not installed, using pre-generated C source file.
warnings.warn('Cython not installed, using pre-generated C source file.')
running install
running build
running build_ext
building 'lsm' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c lsm.c -o build/temp.linux-x86_64-3.6/lsm.o
lsm.c:32:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/home/ec2-user/<project>/venv/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bhhmd3j8/lsm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-__gotpo6/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/<project>/venv/include/site/python3.6/lsm-db" failed with error code 1 in /tmp/pip-install-bhhmd3j8/lsm-db/
EDIT
Thanks for the pointers, now I installed the python development package on ec2 and tried to install lsm-db again
> sudo yum install python36-devel
...
> pip install lsm-db
Collecting lsm-db
Using cached https://files.pythonhosted.org/packages/17/f2/dc68ecdece424eb206c42b8db924c5a7f6dd97d26df42a1c9fb41a6fe555/lsm-db-0.6.4.tar.gz
Building wheels for collected packages: lsm-db
Building wheel for lsm-db (setup.py) ... done
Stored in directory: /home/ec2-user/.cache/pip/wheels/ed/32/8a/b0f3aa15b68f1e6b8f2dcc6285de4796b6b58af71c5f280f48
Successfully built lsm-db
Installing collected packages: lsm-db
Successfully installed lsm-db-0.6.4
again, it shows it's successful, and which python gives me the right python in my venv. However, I have the exact same result as the beginning, pip list does not have lsm-db and I cannot import it in python.
This is entirely an issue on ec2, I can successfully use lsm-db in my virtualenv on my mac. There must be something off with virtualenv on ec2 here, why the right pip in venv cannot install a package in venv?? I'm completely lost. If anyone has experience please chime in!
(To work around this problem, I'm switching from lsm-db to sqlitedict in my code. sqlitedict can be installed no problem, so it narrows the suspect down to just lsm-db specific issues.)
This question from 2016 is more similar to mine but it has no conclusion why or any solution.
Pip says that pymongo has been installed, but doesn't show it as installed
Another potentially related question:
Amazon EC2 virtualenv: pip says it installed numpy but python can't find it
The problem seems to be with system file permissions. You can check the owner:group as well as rwx permissions for other users of the folder '/home/ec2-user/.cache/pip' from terminal using:
ls -lh /home/ec2-user/.cache/pip
In order to change the owner of the folder use command:
sudo chown -R ec2-user /home/ec2-user/.cache/pip
Another way to solve is to allow rwx permissions to all users by:
sudo chmod -R 777 /home/ec2-user/.cache/pip

How can I fix this error very time I try type pip install mysql-python

I have been trying to install python-MySQLdb on mac and I keep getting error. I have tried so many alternatives to pass that error.
sudo PATH=/usr/local/Cellar/mysql/bin/:$PATH pip install mysql-python
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
The directory '/Users/zuhairhallak/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/zuhairhallak/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysql-python
Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 2.6MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-RtF2js/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-RtF2js/mysql-python/
I have also ran sudo -H pip install mysql-python and I got different error
13 warnings generated.
cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.15/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
Failed building wheel for mysql-python
Running setup.py clean for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/private/tmp/pip-install-3A8kOd/mysql-python/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/tmp/pip-record-TUb4up/install-record.txt --single-version-externally-managed --compile
Please try
brew install mysql
sudo -H pip install mysql-python
I went to the mysql_config file and opened it up
vi mysql_config
This was correct.
Create options:
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"
ran this command in terminal
1. export LDFLAGS="-L/usr/local/opt/openssl/lib"
2. export CPPFLAGS="-I/usr/local/opt/openssl/include"
3. pip install mysql-python

Unable to Install Python Package

In trying to install a python package via pip I get the error:
Failed building wheel for atari-py
Running setup.py clean for atari-py
Failed to build atari-py
Installing collected packages: atari-py, PyOpenGL
Running setup.py install for atari-py ... error
Complete output from command C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\xxxxxx\\appdata\\local\\temp\\pip-build-qhuh1q\\atari-py\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\xxxxxx\appdata\local\temp\pip-z8wnzs-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
Unable to execute 'make build -C atari_py/ale_interface -j 3'. HINT: are you sure `make` is installed?
error: [Error 2] The system cannot find the file specified
In my system when I type make:
C:\Users\xxxxxx>make
'make' is not recognized as an internal or external command,
operable program or batch file.
So, clearly make is missing. But I installed make using conda:
C:\Users\xxxxxx>conda install mingw
Fetching package metadata .........
Solving package specifications: ..........
# All requested packages already installed.
# packages in environment at C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2:
#
mingw 4.7
So I have mingw 4.7 already installed.
How could I remove the error and get the package?
Many thanks for the help.
make is not in your PATH.
Do echo %PATH% and check if the path to your msys utilities is in there. Otherwise you can edit this variable by following the instructions here: Adding directory to PATH Environment Variable in Windows

Categories