stevenlovegrove / Pangolin

Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.
MIT License
2.39k stars 855 forks source link

Unable to compile: mpip not found #957

Closed firth650 closed 1 month ago

firth650 commented 1 month ago

Hi I'm unable to get this to compile, first error relates to no mpip, as copied below. Thereafter, I tried to run pypangolin_pip_install just in case the error was not important, but to no avail.

Compile commands were as below

git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
cmake -B build -D BUILD_TESTS=ON
cmake --build build -t pypangolin_pip_install

.......

First/only compile error was near to the end below "gmake[3] mpip...."

[ 98%] Built target pypangolin
[ 98%] Creating Wheel /home/robot/pidog/MyVarious/SLAMopencvtut/Pangolin/build/pypangolin-0.9.2-cp311-cp311-linux_aarch64.whl
[ 98%] Built target pypangolin_wheel
[100%] Installing for selected Python ''
gmake[3]: mpip: No such file or directory
[100%] Built target pypangolin_pip_install

robot@robot: $ pypangolin_pip_install

-bash: pypangolin_pip_install: command not found

Trying import VIA python... robot@robot: $ python Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import pangolin Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pangolin'

christian-rauch commented 1 month ago

Please provide more details about your system setup and how you installed dependencies.

The formatting of the issue description is a bit off, I tried to fix this. It looks like something went wrong with the Python detection.

The mpip: No such file or directory relates to: https://github.com/stevenlovegrove/Pangolin/blob/74be1886139acdb7eceef368edf574101c95e487/cmake/MakePythonWheel.cmake#L97 where the pip module is supposed to be executed by Python (COMMAND ${Python_EXECUTABLE} -mpip). But it looks like that ${Python_EXECUTABLE} is actually empty and [100%] Installing for selected Python '' also suggest that something with the Python detection went wrong. Something that does not make sense here is that the built reports success ([100%] Built target pypangolin_pip_install) while the previous command failed. I'll have a look at this.

How did you install Python?

Then I don't understand why you are trying to execute the command pypangolin_pip_install. That is a target to be built. Since the wheel file built failed, there is nothing to install or import in Python.

firth650 commented 1 month ago

Thanks for the quick reply. I'm running this on a raspberry pi4 under bookworm 64-bit.

I installed the dependencies as below, from here

https://github.com/spmallick/learnopencv/tree/master/Monocular%20SLAM%20for%20Robotics%20implementation%20in%20python.

(Before finding your page)

sudo apt-get install libglew-dev sudo apt-get install cmake sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev sudo apt-get install libdc1394-22-dev libraw1394-dev sudo apt-get install libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev

This libdc1394-22-dev was not found, so I installed this libdc1394-dev instead. Otherwise no issues.

The compilation step from the page mentioned above gave me several compile errors, I then found your page and followed that exactly. Unfortunately, I cannot remember how I installed python, I've had it on my computer for many months now, I'm running python Version 3.11.2

During this stage... "cmake -B build' My correct version of python was reported.

......

Then I don't understand why you are trying to execute the command pypangolin_pip_install. That is a target to be built. Since the wheel file built failed, there is nothing to install or import in Python.

-> My mistake, I was just trying to understand what was going on. but this

not make sense here is that the built reports success ([100%] Built target pypangolin_pip_install

made me think it may have built, I wasn't sure.

christian-rauch commented 1 month ago

I installed the dependencies as below, from here

https://github.com/spmallick/learnopencv/tree/master/Monocular%20SLAM%20for%20Robotics%20implementation%20in%20python.

But that points to a different and very old Pangolin fork.

The compilation step from the page mentioned above gave me several compile errors, I then found your page and followed that exactly. Unfortunately, I cannot remember how I installed python, I've had it on my computer for many months now, I'm running python Version 3.11.2

This repo has a README with installation instructions. Those point to a script that installs all required dependencies.

Can you check if https://github.com/stevenlovegrove/Pangolin/pull/958 solves your problem?

The ${Python_EXECUTABLE} may be undefined in your case. I replaced this with ${Python3_EXECUTABLE} which will only be set when find_package(Python3) is successful.

firth650 commented 1 month ago

Hi yes, that now compiles successfully and creates a valid wheel,

[100%] Built target pypangolin [100%] Creating Wheel /home/robot/pidog/MyVarious/SLAMopencvtut/Pangolin/build/pypangolin-0.9.2-cp311-cp311->>linux_aarch64.whl [100%] Built target pypangolin_wheel

However, (and this may be out of your project remit), The following fails

[100%] Installing for selected Python '/usr/bin/python3'

Did not install. This was expected though and is caused by the latest OS's requirement to either install into a venv or create a Debian-packaged package. The output of the above command is

Installing for selected Python '/usr/bin/python3'
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

I thus installed the pangolin wheel using --break-system-packages, i.e.

pip install /home/robot/pidog/MyVarious/SLAMopencvtut/Pangolin/build/pypangolin-0.9.2-cp311-cp311-linux_aarch64.whl --break-system-packages

This fix has then corrected my bug as reported: Thank you.

FYI The pangollin "PythonExamples" also work fine,

However, this install method (break system packages) did  break my other python scripts (numpy versions differences), and I have reverted to a previous image. So I cannot unfortunately use pangolin in my environment.
christian-rauch commented 1 month ago

The externally-managed-environment error is a new "feature" that prevents overriding system packages. It is the default behaviour for newer Ubuntu and Debian systems and probably other Linux distributions too. See https://packaging.python.org/en/latest/specifications/externally-managed-environments/#externally-managed-environments for details on this behaviour and details and https://github.com/pypa/pip/issues/11776 for additional information and options to force that behaviour part from --break-system-packages.

firth650 commented 1 month ago

Thanks. Yes, I have successfully used some of those solutions over the last 15 months or so. More often than not, I've found the debian-packaged equivalent python library e.g python3-xyz and thus been able it install via apt. However, for my current project, if I'm to include Pangolin then as far as I understand it, I would need both numpy v1 and v2, running in the same venv, which I do not think is possible.

From your reference, (thanks!), I may be able to do something with search paths, but I do not have the skills to do that.

Again, many thanks for the fix and tips. Much appreciated