# ImportError: dlopen(...). HELP!

**URL:** <https://discuss.python.org/t/importerror-dlopen-help/18848>\
**Category:** Python Help\
**Tags:** help, error-handling\
**Created:** [September 7, 2022, 1:56pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848 "2022-09-07T13:56:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulini](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@paulini](https://discuss.python.org/u/paulini)\
**Post date:** [September 7, 2022, 1:56pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/1 "2022-09-07T13:56:32Z")

</div>

I’m very new to Python, only used a few commands before. I’m using CumulusCI for building an application on the Salesforce platform, and I’m running into the following errors every time I use a cci (Cumulus) command. I uninstalled & installed again Cumulus and Python, and several other dependencies to see if that will fix the issue, but I hit the wall now. I understand these errors are very specific to my environment, and there are hints in them, but if anyone could help me understand and navigate what I need to do now, that would be great! I’m on MacOS Monterey v 12.5.1.

```auto
Traceback (most recent call last):
File "/Users/username/.local/bin/cci", line 5, in <module>
from cumulusci.cli.cci import main
File "/Users/username/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/cli/cci.py", line 17, in <module>
from cumulusci.utils import get_cci_upgrade_command
File "/Users/username/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/utils/ __init__.py", line 17, in <module>
from .xml import ( # noqa
File "/Users/username/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/utils/xml/ __init__.py", line 5, in <module>
from lxml import etree as lxml_etree
ImportError: dlopen(/Users/username/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so, 0x0002): tried: '/Users/usernamel/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

```

---

<div class="post-metadata">

**Author:** ![aivarpaalberg](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aivarpaalberg/32/9457_2.png) [@aivarpaalberg](https://discuss.python.org/u/aivarpaalberg)\
**Post date:** [September 7, 2022, 2:22pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/2 "2022-09-07T14:22:08Z")

</div>

> [@paulini](#):
>
> `mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))`

As I read it you have software for Intel based computer but you have one with Apple Silicon.

---

<div class="post-metadata">

**Author:** ![ronaldoussoren](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ronaldoussoren/32/61_2.png) [@ronaldoussoren](https://discuss.python.org/u/ronaldoussoren)\
**Post date:** [September 7, 2022, 2:22pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/3 "2022-09-07T14:22:17Z")

</div>

The error indicates that you are on a system with Apple Silicon (M1/M2) using a Python that natively supports this CPU, and that the lxml extension only supports the Intel architecture.

You could try using `arch -x86_64 cci` to start the script, that should run it in Intel mode assuming that your Python installation supports this.

A proper fix is to reinstall the lxml package into the virtual environment used by pipx.

---

<div class="post-metadata">

**Author:** ![paulini](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@paulini](https://discuss.python.org/u/paulini)\
**Post date:** [September 7, 2022, 6:32pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/4 "2022-09-07T18:32:59Z")

</div>

Thank you for your response!

Ronald, I used pipx to uninstall & install lxml with the following result:

```auto
$ pipx uninstall lxml
Nothing to uninstall for lxml 😴

```

```auto
$ pipx install lxml
No apps associated with package lxml or its dependencies. If you are attempting to install a library, pipx should not be used. Consider using pip or a similar tool instead.

```

Then I re-installed lxml with pip with successful output, but when I run cci, initial errors remain.

Starting script with arch -x86\_64 cci also, unfortunately, didn’t work for me, example:

```auto
arch -x86_64 cci version

arch: posix_spawnp: cci: Bad CPU type in executable

```

Anything else I can try to get it fixed?

---

<div class="post-metadata">

**Author:** ![ronaldoussoren](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ronaldoussoren/32/61_2.png) [@ronaldoussoren](https://discuss.python.org/u/ronaldoussoren)\
**Post date:** [September 8, 2022, 8:15am UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/5 "2022-09-08T08:15:24Z")

</div>

`pipx inject --force cumulusci lxml` might work, although I haven’t tested this.

The `arch` error means that the Python installation on you system only supports arm64 (Apple Silicon) and not x86\_64 (Intel).

What I don’t understand is why pipx installed a wheel for lxml that’s not compatible with the interpreter you’re using.

---

<div class="post-metadata">

**Author:** ![GreenB](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@GreenB](https://discuss.python.org/u/GreenB)\
**Post date:** [September 27, 2022, 9:22am UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/6 "2022-09-27T09:22:25Z")

</div>

Hi @paulini , Did you get a resolution to this? I have been facing the same issue with no luck trying to resolve it.

---

<div class="post-metadata">

**Author:** ![paulini](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@paulini](https://discuss.python.org/u/paulini)\
**Post date:** [September 29, 2022, 5:09pm UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/7 "2022-09-29T17:09:38Z")

</div>

My teammate helped me resolve the issue. We found out that for some reason I had homebrew installed twice, on both x86\_64 and arm64e - most likely because I had a check for “Open using Rosetta” checked in my terminal, so I had to install homebrew before, and after checking the checkbox. Running it in both environments caused the mismatch and the errors above. We needed to re-install all my dependencies, eventually resolving the issue.

---

<div class="post-metadata">

**Author:** ![Vaibhav](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@Vaibhav](https://discuss.python.org/u/Vaibhav)\
**Post date:** [April 12, 2023, 11:45am UTC](https://discuss.python.org/t/importerror-dlopen-help/18848/8 "2023-04-12T11:45:00Z")

</div>

@paulini Could you please help me with step by step process you did to eliminate this error. I am with this error from some days now, trying to figure out a solution.

Thanks in advance!
