0

I have a very similar issue to this question M1 mac: mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') - python

I am trying to import tensorflow_probability in jupyter-lab, in a conda environment, on an M1 macbook pro.

This is my error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [1], in <cell line: 5>()
      3 import tensorflow as tf
----> 4 import tensorflow_probability as tfp



File ~/miniforge3/envs/venv/lib/python3.8/site- 
packages/tensorflow_probability/__init__.py:20, in <module>
     15 """Tools for probabilistic reasoning in TensorFlow."""
     17 # Contributors to the `python/` dir should not alter this file; instead update
     18 # `python/__init__.py` as necessary.
---> 20 from tensorflow_probability import substrates
     21 # from tensorflow_probability.google import staging  # DisableOnExport
     22 # from tensorflow_probability.google import tfp_google  # DisableOnExport
     23 from tensorflow_probability.python import *  # pylint: disable=wildcard-import

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/substrates/__init__.py:21, in <module>
     18 from __future__ import division
     19 from __future__ import print_function
---> 21 from tensorflow_probability.python.internal import all_util
     22 from tensorflow_probability.python.internal import lazy_loader  # pylint: disable=g-direct-tensorflow-import
     25 jax = lazy_loader.LazyLoader(
     26     'jax', globals(),
     27     'tensorflow_probability.substrates.jax')

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/__init__.py:142, in <module>
    139 if _tf_loaded():
    140   # Non-lazy load of packages that register with tensorflow or keras.
    141   for pkg_name in _maybe_nonlazy_load:
--> 142     dir(globals()[pkg_name])  # Forces loading the package from its lazy loader.
    145 all_util.remove_undocumented(__name__, _lazy_load + _maybe_nonlazy_load)

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/lazy_loader.py:61, in 
LazyLoader.__dir__(self)
     60 def __dir__(self):
---> 61   module = self._load()
     62   return dir(module)

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/lazy_loader.py:44, in LazyLoader._load(self)
     42   self._on_first_access = None
     43 # Import the target module and insert it into the parent's namespace
---> 44 module = importlib.import_module(self.__name__)
     45 if self._parent_module_globals is not None:
     46   self._parent_module_globals[self._local_name] = module

File ~/miniforge3/envs/venv/lib/python3.8/importlib/__init__.py:127, in import_module(name, package)
    125             break
    126         level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/experimental/__init__.py:35, in <module>
     32 from __future__ import print_function
     34 from tensorflow_probability.python.experimental import auto_batching
---> 35 from tensorflow_probability.python.experimental import bijectors
     36 from tensorflow_probability.python.experimental import distribute
     37 from tensorflow_probability.python.experimental import distributions

File ~/miniforge3/envs/venv/lib/python3.8/site -packages/tensorflow_probability/python/experimental/bijectors/__init__.py:17, in <module>
      1 # Copyright 2020 The TensorFlow Probability Authors.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     13 # limitations under the License.
     14 # ============================================================================
     15 """TensorFlow Probability experimental bijectors package."""
---> 17 from tensorflow_probability.python.bijectors.ldj_ratio import forward_log_det_jacobian_ratio
     18 from tensorflow_probability.python.bijectors.ldj_ratio import inverse_log_det_jacobian_ratio
     19 from tensorflow_probability.python.experimental.bijectors.distribution_bijectors import make_distribution_bijector

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/bijectors/__init__.py:23, in <module>
     19 from __future__ import print_function
     21 # pylint: disable=unused-import,wildcard-import,line-too-long,g-importing-member
---> 23 from tensorflow_probability.python.bijectors.absolute_value import AbsoluteValue
     24 from tensorflow_probability.python.bijectors.ascending import Ascending
     25 from tensorflow_probability.python.bijectors.batch_normalization import BatchNormalization

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/bijectors/absolute_value.py:23, in <module>
     19 from __future__ import print_function
     21 import tensorflow.compat.v2 as tf
---> 23 from tensorflow_probability.python.bijectors import bijector
     24 from tensorflow_probability.python.internal import assert_util
     25 from tensorflow_probability.python.internal import dtype_util

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/bijectors/bijector.py:30, in <module>
     28 from tensorflow_probability.python.internal import assert_util
     29 from tensorflow_probability.python.internal import auto_composite_tensor
---> 30 from tensorflow_probability.python.internal import batch_shape_lib
     31 from tensorflow_probability.python.internal import cache_util
     32 from tensorflow_probability.python.internal import dtype_util

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/batch_shape_lib.py:23, in <module>
     20 import numpy as np
     21 import tensorflow.compat.v2 as tf
---> 23 from tensorflow_probability.python.internal import prefer_static as ps
     24 from tensorflow_probability.python.internal import tensor_util
     25 from tensorflow_probability.python.internal import tensorshape_util

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/prefer_static.py:30, in <module>
     28 from tensorflow_probability.python.internal import dtype_util
     29 from tensorflow_probability.python.internal import tensorshape_util
---> 30 from tensorflow_probability.python.internal.backend import numpy as nptf
     32 # Try catch required to avoid breaking Probability opensource presubmits.
     33 # TODO(amitpatankar): Remove this once tf-nightly has latest code.
     34 # pylint: disable=g-import-not-at-top
     35 try:

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/backend/numpy/__init__.py:22, in <module>
     19 from __future__ import print_function
     21 from tensorflow_probability.python.internal.backend.numpy import __internal__
---> 22 from tensorflow_probability.python.internal.backend.numpy import bitwise
     23 from tensorflow_probability.python.internal.backend.numpy import compat
     24 from tensorflow_probability.python.internal.backend.numpy import config

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/backend/numpy/bitwise.py:23, in <module>
     19 from __future__ import print_function
     21 import numpy as np
---> 23 from tensorflow_probability.python.internal.backend.numpy import _utils as utils
     25 __all__ = [
     26     'bitwise_xor',
     27     'left_shift',
     28 ]
     31 bitwise_xor = utils.copy_docstring(
     32     'tf.bitwise.bitwise_xor',
     33     lambda x, y, name=None: np.bitwise_xor(x, y))  # pylint: disable=unused-argument

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/backend/numpy/_utils.py:26, in <module>
     23 import types
     25 import numpy as np
---> 26 from tensorflow_probability.python.internal.backend.numpy import nest
     28 try:
     29   from tensorflow.python.ops import array_ops  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top,unused-import

File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tensorflow_probability/python/internal/backend/numpy/nest.py:34, in <module>
     32 from collections import abc as collections_abc
     33 import types
---> 34 import tree as dm_tree
     36 # pylint: disable=g-import-not-at-top
     37 try:

 File ~/miniforge3/envs/venv/lib/python3.8/site-packages/tree/__init__.py:40, in <module>
     37   typing_available = True
     39 try:
---> 40   from tree import _tree
     41 except ImportError:
     42   if "sphinx" not in sys.modules:

ImportError: dlopen(/Users/martin/miniforge3/envs/venv/lib/python3.8/site-packages/tree/_tree.cpython-38-darwin.so, 0x0002): tried: '/Users/martin/miniforge3/envs/venv/lib/python3.8/site-packages/tree/_tree.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

I have tried following the advice given in the other thread, but without success, e.g. "conda install -c conda-forge tree" (since this seems to replace lxml in my issue).

I appreciate any advice!

4
  • 1
    Not sure what you expect in terms of additional answers. "This is a case of some python libraries not being compiled for M1 Apple Silicon CPUs, but only for Intel" seems to be spot-on, so either make sure they are all compiled for M1 or use Rosetta.
    – nohillside
    Apr 6, 2022 at 8:09
  • Thank you for your replies. I suppose I asked the question because the information/solution in the duplicate was not enough for me to solve the problem. Perhaps I should've turned elsewhere for more help, if so I apologise. Sorry I do not quite understand what you mean by installing it in a different place, what do you mean? I have also tried "pip install tree --no-binary :all:" without success. Apr 6, 2022 at 10:24
  • How exactlyu did you setup the conda environment e,g, the steps needed so we can replicate your setup
    – mmmmmm
    Apr 6, 2022 at 12:03
  • Trying to do this - looking at the tree package it does not install any libs just the tree executable which is arm - so we need to see the command to install the tree library
    – mmmmmm
    Apr 6, 2022 at 12:22

0

Browse other questions tagged .