OpenCV Python Building wheel for dlib (setup.py) - python

I am trying to install face_recognition on Ubuntu.
I keep running into this loop, which goes on forever. Please help.
pip install face_recognition
Collecting face_recognition
Using cached https://files.pythonhosted.org/packages/3f/ed/ad9a28042f373d4633fc8b49109b623597d6f193d3bbbef7780a5ee8eef2/face_recognition-1.2.3-py2.py3-none-any.whl
Collecting Pillow (from face_recognition)
Using cached https://files.pythonhosted.org/packages/c1/e6/ce127fa0ac17775bc7887c432ffe945c49ae141f01b477b7cd5e63b16bb5/Pillow-6.0.0-cp37-cp37m-manylinux1_x86_64.whl
Requirement already satisfied: numpy in ./.virtualenvs/cv/lib/python3.7/site-packages (from face_recognition) (1.16.3)
Collecting Click>=6.0 (from face_recognition)
Using cached https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Collecting dlib>=19.7 (from face_recognition)
Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz
Building wheels for collected packages: dlib
Building wheel for dlib (setup.py) .

Add -vvv to see if the installation is progressing.
I also was in that loop, it took a long time but it finished.
pip install dlib -vvv

this is my step-by-step solution
apt-get update
apt-get install build-essential cmake
apt-get install libopenblas-dev liblapack-dev
apt-get install libx11-dev libgtk-3-dev
apt-get install python python-dev python-pip
apt-get install python3 python3-dev python3-pip
then install dlib
cd ~
mkdir temp
cd temp
git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build; cd build; cmake ..; cmake --build .
cd ..
python3 setup.py install
then install face_recognition
pip3 install numpy scipy matplotlib pandas face_recognition

Although I don't know the cause of the loop, I found a workaround by creating a (Anaconda) container with python version 3.6.9 (whereas at first I tried to install face_recognition with python version 3.7.3. Hope it helps.

Related

Unable to install PyQt5 on Ubuntu 20.04

I am trying to install PyQt5 on a freshly installed Ubuntu 20.04 (I need that specific version for compatibility issues).
I have (at least) the following packages installed:
mcon#lucid:~$ sudo apt install -y git python3 build-essential cmake pkg-config googletest libgtest-dev libasound-dev libtinyxml2-dev libsndfile-dev python3-venv qt5-default
I install with:
mcon#lucid:~/audioservices$ pushd tools/client
~/audioservices/tools/client ~/audioservices
mcon#lucid:~/audioservices/tools/client$ python3 -m venv venv
mcon#lucid:~/audioservices/tools/client$ venv/bin/pip install -r requirements.txt
Collecting PyQt5
Downloading PyQt5-5.15.9.tar.gz (3.2 MB)
|████████████████████████████████| 3.2 MB 1.3 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... -Killed
Content of reqirements.txt is:
PyQt5
bottle~=0.12.23
cffi~=1.15.1
What happens is pip slowly eats all my memory (I have 4GB, almost completely free) and finally gets Killed for its greediness.
What am I doing wrong?

ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

I was trying to install OpenCV4 in a docker on jetson nano. It has jetpack 4.4 s os. The docker was successfully created and Tensorflow is running but while installing OpenCV using pip it is showing CMake error.
root#5abf405fb92d:~# pip3 install opencv-python
Collecting opencv-python
Downloading opencv-python-4.4.0.42.tar.gz (88.9 MB)
|████████████████████████████████| 88.9 MB 2.5 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from opencv-python) (1.18.4)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpqpzwrofy
cwd: /tmp/pip-install-93nxibky/opencv-python
Complete output (9 lines):
File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
"Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
Traceback (most recent call last):
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
I had the same problem and i did this,
pip install --upgrade pip setuptools wheel
then install opencv again,
pip install opencv-python
this worked for me
If after
pip install --upgrade pip setuptools wheel
you still have the same error,
You can try to specify the older version of OpenCV to install.
Ex.
pip3 install opencv-python==3.4.13.47
Yes .. Finally found a work around.
Follow this https://github.com/mdegans/nano_build_opencv and build from source and finally gets installed.
PS: It may take a bit long for building, for me it took 10 Hrs :P.
Happy Image-Processing..
I had a similar problem and what solved it for me was not to use python:3-alpine but python:3.8-slim. E.g.:
FROM python:3.8-slim
WORKDIR /usr/src/app
RUN apt update
RUN apt -y install build-essential libwrap0-dev libssl-dev libc-ares-dev uuid-dev xsltproc
RUN apt-get update -qq \
&& apt-get install --no-install-recommends --yes \
build-essential \
gcc \
python3-dev \
mosquitto \
mosquitto-clients
RUN pip3 install --upgrade pip setuptools wheel
RUN python3 -m pip install --no-cache-dir \
numpy scipy matplotlib scikit-build opencv-contrib-python-headless \
influxdb paho-mqtt configparser Pillow \
qrcode
worked finally for me.
please check your python specifications:
- opencv -> python[
version='
>=2.7,<2.8.0a0
>=3.5,<3.6.0a0
>=3.6,<3.7.0a0
>=3.7,<3.8.0a0']
I handled it by reinstalling python3 from scratch in my MacBook:
brew reinstall python#3.9
I also reinstalled numpy and matplotlib packages experimentally.
pip3 install numpy
pip3 install matplotlib
pip3 install opencv-contrib-python
The versions:
macOS Mojave 10.14.5
Python 3.9.7
OpenCV 4.5.3
OpenCV's version is 4.5.3 by this way:
import cv2
print(cv2.__version__)
But by "pip list", it shows "opencv-contrib-python 3.4.9.31".
if you are trying to install opencv in your raspberrypi 3B, Use following steps:
sudo raspi-config
advanced -- expand filesystem
reboot your pi
Open your raspi terminal and do following stuff:
use command: sudo apt-get update
use command: sudo apt-get upgrade
check your python version and upgarde it to latest one
install pip and upgrade pip
use command: mkdir project
use command: cd project
create virtual environment
activate virtual environment
install dependencies ,can get dependencies from https://singleboardbytes.com/647/install-opencv-raspberry-pi-4.htm
if error in installing libdhf5-dev
use command: sudo apt-get install python3-h5py and reinstall libdhf5-dev
use command: pip install scikit-build
use command: pip install cython
before installing opencv ,make sure you are in virtual environment or
activate environment
use command: pip install --no-cache-dir opencv-contrib-python==4.5.3.56
Remember to use mentioned version...
Thank You...
I came across similiar situation
I had error
Failed to build opencv-python ERROR: Could not build wheels for
opencv-python which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 19.2.3, however version 22.0.4 is
available. You should consider upgrading via the 'python -m pip
install --upgrade pip' command.
I ran in command prompt with admin privileges following
python -m pip install --upgrade pip
Now "pip install opencv-python" works

Robot framework Ride installation issue on Ubuntu OS

I have done all installation related to robot framework but when I install robot framework-ride that time through some error on the command line "Could not find a version that satisfies the requirement Pywin32 (from robotframework-ride)".
1.sudo apt-get install python-wxgtk2.8
python-wxgtk2.8 is already the newest version (2.8.12.1+dfsg-2ubuntu2).
The following packages were automatically installed and are no longer required:
2.pip install robotframework
Requirement already satisfied: robotframework in /usr/local/lib/python2.7/dist-packages (3.1.1)
sudo pip install robotframework-ride
Collecting Pywin32 (from robotframework-ride)
Could not find a version that satisfies the requirement Pywin32 (from robotframework-ride) (from versions: )
No matching distribution found for Pywin32 (from robotframework-ride)
Expected: robot framework should be installed successfully on my ubuntu os.
Actual result : 'sudo pip install robotframework-ride'
Collecting Pywin32 (from robotframework-ride)
Could not find a version that satisfies the requirement Pywin32 (from robotframework-ride) (from versions: )
No matching distribution found for Pywin32 (from robotframework-ride)
Try :
sudo apt-get install -y \
libgstreamer-plugins-base1.0-dev \
libwxgtk-webview3.0-gtk3-dev
then :
sudo apt-get install -y libgtk2.0-dev libgtk-3-dev \
libjpeg-dev libtiff-dev \
libsdl1.2-dev libgstreamer-plugins-base0.10-dev \
libnotify-dev freeglut3 freeglut3-dev libsm-dev \
libwebkitgtk-dev libwebkitgtk-3.0-dev
This took a long time, ~30min
after :
pip install -U -r https://raw.githubusercontent.com/robotframework/RIDE/master/requirements.txt
Finally :
git clone git#github.com:robotframework/RIDE.git
cd RIDE
python setup.py build
sudo python setup.py install
Run Ride :
ride.py &
Reference : https://github.com/robotframework/RIDE/issues/1811
Ir you want, you can install newest development version, with:
sudo pip install -U https://github.com/robotframework/RIDE/archive/master.zip

Why can't I install Cassandra-driver

I am studying Cassandra by its document.
But when I use "pip install cassandra-driver" to install cassandra-driver ,failed like this:
weikairen2#weikairen2-virtual-machine:~$ pip install cassandra-driver
Collecting cassandra-driver
Using cached cassandra-driver-3.7.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): six>=1.6 in ./.local/lib/python2.7/site-packages (from cassandra-driver)
Requirement already satisfied (use --upgrade to upgrade): futures in ./.local/lib/python2.7/site-packages (from cassandra-driver)
Building wheels for collected packages: cassandra-driver
Running setup.py bdist_wheel for cassandra-driver ...
^Z
[1]+ 已停止 pip install cassandra-driver
weikairen2#weikairen2-virtual-machine:~$ ls
cassandra jdk 公共的 图片 音乐
cassandra-driver-3.7.0 pycharm 模板 文档 桌面
examples.desktop PycharmProjects 视频 下载
weikairen2#weikairen2-virtual-machine:~$ cd cassandra-driver-3.7.0
weikairen2#weikairen2-virtual-machine:~/cassandra-driver-3.7.0$ ls
cassandra ez_setup.py MANIFEST.in README.rst setup.py
cassandra_driver.egg-info LICENSE PKG-INFO setup.cfg
weikairen2#weikairen2-virtual-machine:~/cassandra-driver-3.7.0$ python setup.py install
^Z
[2]+ 已停止 python setup.py install
weikairen2#weikairen2-virtual-machine:~/cassandra-driver-3.7.0$ python setup.py build
as you can see,there is no response
and I have to stop it by ctrl+z
I also tried manul install
no response again
So where is the error? How can I fix it?
I figure out
"sudo pip install cassandra-driver"
it takes a little long time
I was just too impatient
It takes a long time, ~10mins in some environments. You can use
$ # installing from source
$ CASS_DRIVER_BUILD_CONCURRENCY=8 python setup.py install
$ # installing from pip
$ CASS_DRIVER_BUILD_CONCURRENCY=8 pip install cassandra-driver
to speed it up.
Source: https://docs.datastax.com/en/developer/python-driver/3.25/installation/

Why does my numpy install keeps being KILLED?

here's what I am trying to do on Coding Ground
sh-4.3$ pip install --target=. virtualenv
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting virtualenv
Downloading virtualenv-15.0.2-py2.py3-none-any.whl (1.8MB)
100% |################################| 1.8MB 204kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv
sh-4.3$ python virtualenv.py mine
New python executable in /home/cg/root/mine/bin/python
Installing setuptools, pip, wheel...done.
sh-4.3$ . mine/bin/activate
(mine) sh-4.3$ pip install numpy
Collecting numpy
Downloading numpy-1.11.0-cp27-cp27mu-manylinux1_x86_64.whl (15.3MB)
99% |############################### | 15.3MB 43.1MB/s eta 0:00:01Killed
(mine) sh-4.3$
Why does my trying of installation of numpy keep being killed?
And how do i solve this problem?
A quick fix for this would be to add swap memory. Here's an Ubuntu example:
sudo mkdir /media/fasthdd
dd if=/dev/zero of=/media/fasthdd/swapfile.img bs=1024 count=1M
sudo mkswap /media/fasthdd/swapfile.img
sudo swapon /media/fasthdd/swapfile.img
Don't forget to turn it off if you don't need it.

Categories