How to install mediapipe with miniforge3? - python

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.

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.

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).
Follow this tutorial for installing tensorflow on M1 (https://towardsdatascience.com/installing-tensorflow-on-the-m1-mac-410bb36b776) up to point 3.
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
Activate the environment
conda activate my_env
Install the mediapipe package, and other packages like opencv.
pip install mediapipe
pip install opencv-python
Check that all packages are installed.
Python
>>> import tensorflow
>>> import mediapipe
>>> import cv2

Related

ModuleNotFoundError: No module named 'geopandas' [duplicate]

This error raised while installing geopandas. I've looking for its solution on the web, but none of them really explain what happened and how to solve it..
This is the full error:
Collecting geopandas
Using cached https://files.pythonhosted.org/packages/24/11/d77c157c16909bd77557d00798b05a5b6615ed60acb5900fbe6a65d35e93/geopandas-0.4.0-py2.py3-none-any.whl
Requirement already satisfied: shapely in c:\users\alvaro\anaconda3\envs\tfdeeplearning\lib\site-packages (from geopandas) (1.6.4.post2)
Requirement already satisfied: pandas in c:\users\alvaro\anaconda3\envs\tfdeeplearning\lib\site-packages (from geopandas) (0.20.3)
Collecting fiona (from geopandas)
Using cached https://files.pythonhosted.org/packages/3a/16/84960540e9fce61d767fd2f0f1d95f4c63e99ab5d8fddc308e8b51b059b8/Fiona-1.8.4.tar.gz
Complete output from command python setup.py egg_info:
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Alvaro\AppData\Local\Temp\pip-install-oxgkjg8l\fiona\
pip install wheel
pip install pipwin
pipwin install numpy
pipwin install pandas
pipwin install shapely
pipwin install gdal
pipwin install fiona
pipwin install pyproj
pipwin install six
pipwin install rtree
pipwin install geopandas
here are the source links:
http://geopandas.org/install.html#installation
https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
If you still have problems, consider uninstalling the above (pip uninstall) and reinstalling.
I solved this problem by running the following commands:
pip install pipwin
pipwin install gdal
pipwin install fiona
pip install geopandas
Works successfully on Windows.
Geospatial Data Abstraction Library (GDAL) is a library designed for vector geospatial data formats. It's a prerequisite for installing Fiona, the Python API for OGR (which doesn't really stand for anything), which is in turn a prerequisite for Geopandas. On UNIX-like systems the gdal-config script tells Fiona stuff about your particular gdal installation.
It seems that your gdal-config is not in one of the usual places on your PATH, so Fiona was unable to find it.
If you're using Anaconda, best is to remove gdal with conda remove gdal and then do a fresh conda install geopandas.
As a general rule, if you're using Conda you should never use pip to install something inside it unless you're absolutely sure conda offers no support for it. (Many package can be found on conda by specifying the right channel - -c argument.) And specifically in the case of geopandas, the maintainers recommend using conda over pip, since pip requires you to install the dependencies correctly.
I had a lot of issues myself installing geopandas, mostly showing error when downloading fiona and gdal. I did every step above and did a conda install geopandas but failed. The only thing worked for me is to install fiona and gdal wheel separately.
go to the link by Christoph: gohlke:https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona
You can search for fiona and gdal wheel files. Make sure you choose the file as per your python version, if it is 3.7 then there would be cp37.
Download the file
go to command prompt, put cd and then pip install , install GDAL wheel file, then fiona, then just do pip install geopandas.
This solution worked for me.
To install gdal, I followed the following steps:
downloaded the version that satisfies my computer (64 bit) from
https://www.lfd.uci.edu/~gohlke/pythonlibs/ . The file was GDAL-3.1.4-cp37-cp37m-win_amd64.whl
Put the file in a folder on the desktop.
From cmd, i moved to that directory and executed python -m pip install GDAL-3.1.4-cp37-cp37m-win_amd64.whl
This is followed by installing fiona the same way: python -m pip install Fiona-1.8.18-cp37-cp37m-win_amd64.whl
For shapely, i executed conda install -c conda-forge shapely
After that, i was able to install keplergl as usual: pip install keplergl
install descartes: conda install -c conda-forge descartes (or python -m pip install descartes).
In this way, i didn't have to play around with the 'Environmental Variables' as this may affect other programs
Cheers..
Installing geopandas
Geopandas has very complex multi-language dependencies, some of which need to be built with consistent compiler versions across packages. Because of this, the geopandas docs recommend installing using conda in a new environment using conda-forge only. Here are some general best practices to keep in mind:
conda is the recommended installation method. You can install geopandas from pip or source, but it's going to be a bumpy ride and it's not recommended. If you're installing conda for the first time, I recommend you start with miniconda (or better yet miniforge, a conda-forge-first miniconda variant), not anaconda, to keep your base env lean.
When using conda, you should not mix and match conda channels.
When installing geopandas, try creating a fresh environment rather than installing into your base environment. If you have anaconda installed, it comes with a large number of packages from the "defaults" channel installed in your base environment. I recommend deleting anaconda and installing miniconda, then installing into a new environment.
Try to create a new environment with everything you plan to use all at once rather than iteratively modifying the environment. In other words, if you want to use geopandas with scikit_learn, folium, and rasterio, install them together with a single conda create command
As a last resort, delete your conda installation and re-install miniconda. Desperate times call for desperate measures, and this usually resolves gnarly installation nightmares.
To create a fresh conda environment in which you install all necessary dependencies at the same time, using the conda-forge channel:
conda create -n my-geopandas-env -c conda-forge geopandas [all other packages you need]
For example, I might set up an environment with something along the lines of...
conda create -n my-geopandas-env -c conda-forge python=3.9 \
ipython ipykernel geopandas scipy seaborn fiona matplotlib cartopy
Bundling your installations into a single environment creation step like this reduces the chance of packages falling out of sync. To speed this process up, you could first install mamba or mambaforge, a faster drop-in replacement for conda, into your base environment and then run the above commands with mamba instead of conda.
Generally, it's best to avoid installing much of anything in your base environment (cross-environment system utilities like mamba are some of the few exceptions). If you already have a complex base environment (maybe you started with anaconda rather than miniconda) this may be the time to delete your entire conda installation and start from scratch (I know that's terrifying... sorry! but it'll save you heartache in the future). mamba is great for speeding this process up.
Connecting your editor to the conda environment
Once you have installed all of the packages you need, activate your environment with conda activate my-geopandas-env. See the conda guide to managing environments for more info.
Jupyter/ipython
Some editors/IDEs including jupyter require additional packages - jupyter requires that ipython and ipykernel be installed in order to load the environment within the notebook or editor - that's why I included ipykernel in my list above. See the ipykernel docs for more info.
Other IDES
To link this environment to an IDE such as VSCODE, spider, etc., find the location of this python version with conda run -n my-geopandas-env which python then point your editor to this python executable. Check the docs of your specific editor to get more targeted info about how to set up a conda environment for use with your editor:
Spider: FAQ on using an existing environment and Spider wiki guide to working with packages and environments
VSCode: Using python environments in vscode
PyCharm: Configure a conda virtual environment
I don't have conda installed, then using just pip I followed these steps:
Download GDAL and Fiona wheels directly on:
GDAL: https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
FIONA: https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona
Then:
pip install <gdal.whl>
pip install <fiona.whl>
In my case I did pip install GDAL-3.4.1-cp38-cp38-win_amd64.whl and Fiona-1.8.21-cp38-cp38-win_amd64.whl. Where cp38 stands for python 3.8.
After that you are able to install geopandas with pip as well.
pip install geo pandas
For me, the only solution was to install the ready binaries from here
https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Then just install locally
pip install GDAL-3.1.4-cp38-cp38-win_amd64.whl
One way in which I could install geopandas was through the Anaconda Navigator. Get into the environment and install the package 'geopandas'. After that I could import the geopandas package in spyder
I will add
!pip install descartes
to #JDOaktown list.
I started with pip install geopandas and got the error, but later tried with conda install --channel conda-forge geopandas and the error disappeared.
Successfully installed in RHEL 7.8.
It automatically downloaded the required packages. This might be helpful
Installing collected packages: certifi, pyproj, shapely, attrs, click, click-plugins, munch, cligj, fiona, geopandas
Successfully installed attrs-20.3.0 certifi-2020.11.8 click-7.1.2 click-plugins-1.1.1 cligj-0.7.0 fiona-1.8.17 geopandas-0.8.1 munch-2.5.0 pyproj-3.0.0.post1 shapely-1.7.1
If you want to install GDAL, Geopandas, Shapely, Fiona etc in a windows Virtual Environment download .whl files for all of them and first install GDAL using
pip install gdal-.whl
Following this command edit the activate.bat file in you venv\Scripts folder and add
GDAL_CONFIG = \venv\Lib\site-packages\osgeo
Then you can install rest using pip install
I started off with a clean environment gdal_test in Conda environments, but made the mistake of using the old activate gdal_test instead of conda activate gdal_test. This made Conda Environment resolving take forever, which is why I resolved to other methods at first.
Takeaway: let conda handle it, with a proper new environment.
I ran into this problem not with anaconda/windows, but with python:3.6 Docker image. Google search always led me to this question, so I think I will share how I resolve my issue in case others also end up here.
Based on here, you need to install system relevant packages in the Dockerfile before running pip install geopandas or pip install requirements.txt:
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libatlas-base-dev \
libgdal-dev \
gfortran
The following worked on macOS:
brew install gdal --HEAD
Verify the installation by running gdal-config --version
Following that pip installation as normal worked without a problem.

Can't install geopandas in Anaconda environment

I am trying to install the geopandas package with Anaconda Prompt, but after I use conda install geopandas an unexpected thing happened:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages
After this, it proceeds to search for conflicts, but hours pass without finishing. In the end, I still cannot use geopandas.
I have also tried installing geopandas in a different virtual environment and it works but I do not know how to use the environment in Jupyter Notebooks.
I would like to know, how can install geopandas without a separate environment?
Or, alternatively, how can I use geopandas in Jupyter Notebooks after install it in a separate environment?
Install it in a new env, and include ipykernel if you plan to use it in Jupyter:
conda create -n my_env geopandas ipykernel
Note, nb_conda_kernels should be installed install in your base env (i.e. where you launch Jupyter from). This enables Jupyter to automatically recognize other envs that are kernel-ready:
conda install -n base nb_conda_kernels
in my case, I installed geos firstly: pip install geos, then conda install geopandas and everything went through.
If you want to install geopandas in an EXISTING environment, use conda-forge as follows:
conda install --channel conda-forge geopandas
I faced the same problem. As far as I understand, my mistake was to install geopandas or pyproj with pip instead of conda. When trying to fix the issue (uninstalling geopandas, pyproj) I completely crashed my env.
I fixed the issue by completely reinstalling anaconda and creating a new separate conda env with an older version of python (python=3.8 instead of 3.9). Then everything ran smoothly.
I had this issue when Jupyter had been installed from the default channel. For me running conda uninstall jupter followed by conda install -c conda-forge geopandas worked.
You can install geopandas with pip, however, geopandas requires other dependencies (such as pandas, fiona, shapely, pyproj, rtree). You need to make sure that they are properly installed. After that you should be able to use them in jupyter with a simple import geopandas.

Conda refuse to install packages from requirements.txt just because of a few outliers, how to fix it?

I'm using requirements.txt to manage my python dependency:
six
tqdm
future
numpy
brine
scipy
matplotlib
# birdseye
shapely
git+https://github.com/tribbloid/jupyerlab-desktop.git#subdirectory=python
jupytext
# pyre-check
# deprecated
torch >= 1.2.0
# tensorboard
# opencv >= 4.0.0
# prototypes
git+https://github.com/pytorch/vision.git#v0.4.0#egg=torchvision
tb-nightly
My environment is a conda env on python 3.7. I was trying to use a few command to install these packages, but when I run:
conda install --file requirements.txt
I got the following error message:
$ conda install --file ./requirements.txt
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:
- tb-nightly
- //github.com/tribbloid/jupyerlab-desktop.git
- torch[version='>=1.2.0']
- //github.com/pytorch/vision.git#v0.4.0
- brine
Current channels:
- https://conda.anaconda.org/conda-forge/linux-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/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.
It appears that conda refuse to install any of them simply because it can't find 3 packages! (they are on PyPI) What's the point of this design and what should I do to fix it?
My end goal is to use conda if possible, and fallback to pip if they are only on PyPI, the entire process should be reproducible and fully automated.
You can delete offending packages from requirements.txt, run conda on the new .txt, then install non-installed packages via pip into your Anaconda/pkgs (or move them there manually post-install). Then, run conda update --all to ensure compatibility.
Worked for me for a similar instance.
This works on Linux. Just install via pip in your conda environment, it won't complain about not finding the packages like conda.
Run pip install -r requirements.txt. This will install the packages in your conda environment plus all their dependencies.
Make sure to activate your environment and that you are running this command in the directory where your requirements.txt is i.e in terminal cd to wherever requirements.txt is.
I thought to try only after installing keras and tensorflow via pip so I can't say 100% that it would've worked for those as well, but everything else in my req file (+50 modules) installed with this command on Win11 in Anaconda Powershell while in the active environment.
conda install -c conda-forge --file requirements.txt
I still don't know why I needed to do this. Also, I tried another req file that I didn't have a problem with weeks prior. It also failed as the OP states. I don't know what I may have done (not done) to cause this. Perhaps missing a conda update or server down.

Installing fbprophet Python on Windows 10

My build keeps failing on windows 10 for installing fbprophet in anaconda with the following message:
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::automat-0.7.0-py_1'.
CondaError: Cannot link a source that does not exist. C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\Scripts\conda.exe
the command that is given is:
conda install -c conda-forge fbprophet
Has anyone successfully installed fbprophet on Windows 10? If yes, then please give the steps.
Thanks.
I tried pip install as well but no luck. I have a Mac and managed to install fbprophet on it without any issues.
First install Anaconda or miniconda in your Windows machine and add conda python path to env variable as default python.
Open your command prompt and run following commands.
Create a conda virtual environment (optional)
conda create -n v-env python=3.7
activate v-env
Install c++ complier
conda install libpython m2w64-toolchain -c msys2
libpython will automatically create and setup distutils.cfg file for you in PYTHONPATH\Lib\distutils, but if that is failed use the following instructions to setup it manually
[OPTIONAL]
create distutils.cfg with text editor (e.g. notepad, notepad++) and add the following lines to that file.
[build]
compiler=mingw32
Install dependencies
conda install numpy cython -c conda-forge
conda install matplotlib scipy pandas -c conda-forge
Install PyStan
pip install pystan
or
conda install pystan -c conda-forge
Install Ephem
conda install -c anaconda ephem
Install fbprophet
pip install fbprophet
or
conda install -c conda-forge fbprophet
I also faced installing facebook prophet issue in windows 10 without conda.
But,we can solve it.
First, uninstall any pystan, fbprophet.
Then follow the steps below,
python.exe -m pip install pystan==2.17.1.0
python.exe -m pip install fbprophet==0.6
python.exe -m pip install --upgrade fbprophet
Thanks,
tsj
Updated: 28 July 2022
As of v1.0, the package name on PyPI is "prophet"; prior to v1.0 it was "fbprophet". fbprophet is now just prophet. A few additional considerations:
From v0.6 onwards, Python 2 is no longer supported.
As of v1.1, the minimum supported Python version is 3.7.
Below one will find how to
Install with PyPI
Install with Anaconda
Install the Development version
1. Istallation in Python using PyPI
Prophet is on PyPI, so one can use pip to install it.
python -m pip install prophet
2. Installation in Python using Anaconda
One might have to access Anaconda Prompt for the environment that one is working with as admin:
And run
conda-forge: conda install -c conda-forge prophet
Or
conda install -c conda-forge prophet -y
3. Development version
To get the latest code changes as they are merged, one can clone this repo and build from source manually. This is not guaranteed to be stable.
git clone https://github.com/facebook/prophet.git
cd prophet/python
python -m pip install -r requirements.txt
python setup.py develop
By default, Prophet will use a fixed version of cmdstan (downloading and installing it if necessary) to compile the model executables. If this is undesired and one would like to use one's existing cmdstan installation, one can set the environment variable PROPHET_REPACKAGE_CMDSTAN to False:
export PROPHET_REPACKAGE_CMDSTAN=False;
Sources
https://facebook.github.io/prophet/docs/installation.html
https://github.com/facebook/prophet
I've had the same problem. But it works after I follow this steps:
On Prompt install Ephem:
conda install -c anaconda ephem
Install Pystan:
conda install -c conda-forge pystan
Finally install Fbprophet
conda install -c conda-forge fbprophet
Latest installation code for 2021:
pip install pystan==2.19.1.1, then pip install prophet
Also, reboot your jupyter notebook after installation
Install without Conda, Win 10, Python 3.8.8 64 bit.
pip3 install Cython
Then install:
Reboot your maching
Install
pip3 install pystan==2.17.1.0
pip3 install fbprophet
Here's my solution. I have not use conda-forge before, so reading up on this article helps.
Making sure that conda is ≥4.9
conda --version
add conda forge channel
conda config --add channels conda-forge
conda --set channel_priority strict
install gcc
conda install gcc
install prophet
conda install -c conda-forge prophet
I used the prophet documentation here
I faced the same issue and my solution was to:-
Create a new environment with Python3.5
conda create -n pht python=3.5 anaconda
Install Prophet using the command.
conda install -c conda-forge fbprophet
I didn't install 'gcc' although this was advised before installing Prophet.
I am using Python 3.8.5 and conda 4.10.1 on a Windows 10 machine.
I was able to install prophet in Anaconda 2.0.1 using command prompt (not as admin), using: conda install -c conda-forge fbprophet
It took some time for it to figure out the details, as you can see from the prompts below, but finally it was able to install the package.
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done

pip install vs. conda install

After activating a virtualenv
source activate myVirtualEnv
how is pip install basemap different from conda install basemap? Both gave me different results, why is that?
pip install basemap
Collecting basemap
Could not find a version that satisfies the requirement basemap (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external basemap to allow).
No matching distribution found for basemap
conda install basemap
Successfully installs
Pip installs from PyPI. There are no releases of the basemap package on PyPI, it is just a simple registration page pointing at the real download location (SourceForge).
Conda pulls from its own repository, typically with convenience builds of libraries common to the community Conda is aimed at. Conda's repository has a version of the basemap package available for installation, so it succeeds.
This is not to say that Pip is "worse" than Conda in this instance, as you could easily download the package and install it with pip locally. This particular library has just opted to not add releases to PyPI.
I solved this problem by example:
conda install pip
pip install js2xml
Because conda install js2xml does not work. On the other hand, conda install openpyxl does work. How do I know which is conda and which is pip. There is a list provided:
conda install js2xml
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- js2xml
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/free/linux-64
- https://repo.anaconda.com/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/pro/linux-64
- https://repo.anaconda.com/pkgs/pro/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
Sames goes for an error when trying to run python script when you added "import js2xml" whilst using acaconda/conda: ModuleNotFoundError: No module named 'js2xml'
If you use conda or anaconda, do NOT install pip by typing "sudo apt install pip".

Categories

Resources