Search code examples
pythonmacoscondazbar

Error installing pyzbar with Conda on Mac OS X


I am attempting to convert a project from a Python 3 venv to Conda. However, it doesn't work with Conda, apparently because there is no repository that supports macOS.

This is disappointing because using brew and pip to install zbar and pyzbar in the original project works fine. So clearly the files exist but are not available through Conda repos. Am I missing a repo somewhere? If not, is there a way to crowbar the packages downloaded with pip and brew into a Conda environment?

Here's what I've tried.

I see instructions which say to use conda install -c lightsource2-tag pyzbar. However Conda fails to resolve (complete error message at the bottom of this note).

This seems consistent with the results of searching https://anaconda.org/search?q=pyzbar . The only repos listed are for Linux and win32.

(NewUI_conda) BlueMorph: /Users/Wes 12:16
516$ conda install -c lightsource2-tag pyzbar
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:

  - pyzbar

Current channels:

  - https://conda.anaconda.org/lightsource2-tag/osx-64
  - https://conda.anaconda.org/lightsource2-tag/noarch
  - https://conda.anaconda.org/conda-forge/osx-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch


Solution

  • Yes, it looks like pyzbar is not available through Anaconda Cloud channels for osx-64 platform. Instead, one can (cautiously) mix PyPI and Conda packages. For example, a basic YAML definition would be something like:

    zbar_env.yaml

    name: zbar_env
    channels:
     - conda-forge
     - defaults
    dependencies:
     - python=3
     - zbar
     - pip
     - pip:
       - pyzbar
    

    which can be instantiated with:

    conda env create -f zbar_env.yaml
    

    As per the recommendations for mixing PyPI and Conda, place all requirements in this YAML file from the start. If you need to add something new, edit the YAML and recreate the env.


    Alternatively, you could switch to zbarlight, which is available through Conda Forge and appears to be consistently maintained.