1

I am on a new Mac M1 trying to install mediapipe and TensorFlow on the same Conda env. Installing both libraries on M1 appear to have a lot of issues. I was finally able to get TensorFlow to install using this tutorial:

https://betterprogramming.pub/installing-tensorflow-on-apple-m1-with-new-metal-plugin-6d3cb9cb00ca

This tutorial requires the Miniforge3 package manager and python 3.9.

I created a Conda env using miniforge3 and TensorFlow works great now.

Now when I try to install mediapipe into this env, with either of these commands:

pip install mediapipe

or

 ~/miniforge3/envs/vision/bin/pip install mediapipe

I get this error:

ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none)
ERROR: No matching distribution found for mediapipe

I've done some looking and found that mediapipe has issues with python >3.7.

I tried downgrading python using this command:

conda install python=3.x

I was able to downgrade to 3.8, but no lower. Python 3.6 and 3.7 were not found by Conda:

(base) % conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - python=3.7

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

What should I do? I need to use both mediapipe and TensorFlow.

merv
  • 67,214
  • 13
  • 180
  • 245
connor449
  • 1,549
  • 2
  • 18
  • 49
  • I don't think mediapipe has any wheels for the M1 architecture. Is running non-natively using Rosetta an option for you – FlyingTeller Apr 29 '22 at 14:03
  • I just found a SO post describing installing using Rosetta. I've never used Rosetta but it looks useful for this case. Here is the post: https://stackoverflow.com/questions/68659865/cannot-pip-install-mediapipe-on-macos-m1 – connor449 Apr 29 '22 at 14:05
  • @FlyingTeller is the plan is to use TensorFlow on the Apple GPU, then emulation wouldn't be a viable option. – merv Apr 29 '22 at 15:48
  • macOS should prompt you to install Rosetta whenever it encounters an x86_64 binary - no need to manually download. The OS will automatically run non-native binaries with Rosetta, so also no need to specifically launch things. However, as my other comment mentions, you likely want a native environment if the plan is to use TensorFlow with the GPU. – merv Apr 29 '22 at 15:51
  • I'm adding an OpenCV tag, since this is a crucial prerequisite for MediaPipe, and that community may have more tractable advice for non-Conda solutions. E.g., `homebrew` appears to have better support for M1 at the moment, at least from the chatter I see on Conda Forge feedstocks. – merv Apr 29 '22 at 15:59
  • Could you please try again by using `pip install mediapipe==0.8.7.1` to install `mediapipe`? –  May 11 '22 at 08:35

2 Answers2

0

First of all, you have to set up your python environment first before considering how to install mediapipe.

I got similar issue once I got my new M1 laptop, and finally resolved by emulating x86_64 Python architecture with command:

CONDA_SUBDIR=osx-64 conda create -n Env37 python=3.7

Once you have done that, you could activate this Python 3.7 environment with command:

source activate Env37

Then run pip install mediapipe to install this specific python package.

DianaDu
  • 43
  • 5
0

My solution was also to create a conda environment with Python 3.7 and x86_64 architecture. Python 3.7 is required for Mediapipe to work with TensorFlow (https://google.github.io/mediapipe/getting_started/install.html).

  1. Follow this tutorial for installing tensorflow on M1 (https://towardsdatascience.com/installing-tensorflow-on-the-m1-mac-410bb36b776) up to point 3.

  2. For point 4, download the environment.yml file with tensorflow dependencies (https://raw.githubusercontent.com/mwidjaja1/DSOnMacARM/main/environment.yml), but modify the line ‘python=3.8’ to ‘python=3.7’. Then create the conda environment using x86_64 architecture:

CONDA_SUBDIR=osx-64 conda env create --file=environment.yml --name my_env
  1. Activate the environment
conda activate my_env 
  1. Install the mediapipe package, and other packages like opencv.
pip install mediapipe
pip install opencv-python
  1. Check that all packages are installed.
Python
>>> import tensorflow
>>> import mediapipe
>>> import cv2
Xi Zhi
  • 1