ImportError: dlopen(...). HELP!

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.

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)))

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

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.

Thank you for your response!

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

$ pipx uninstall lxml
Nothing to uninstall for lxml 😴
$ 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:

arch -x86_64 cci version

arch: posix_spawnp: cci: Bad CPU type in executable

Anything else I can try to get it fixed?

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.

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

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.

@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!