I’m trying to use Python to instantiate some resou...
# python
I’m trying to use Python to instantiate some resources on DigitalOcean. The problem is that I’m using an M1 Mac. When I try to import pulumi, I get an error:
Copy code
ImportError: dlopen(/blah/venv/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 0x0002): tried: '/blah/venv/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
How do I get past this?
I saw a thread from about a week ago that said they fixed it by running Python 3.9, alas, that’s not fixing it for me. Trying other things from that thread as well, hoping something works right.
Sound like you’ve installed amd64(x86_64) instead of arm64 version of Python 3.9 on your M1 laptop
file $(which python3.9)
/blah/venv/bin/python3.9: Mach-O 64-bit executable arm64
I think I got python3 from brew, there’s probably an arch switch I should have used to get the native one
https://github.com/grpc/grpc/issues/28387#issuecomment-1016166913 Then I think you need to pass
when you are installing grpcio
I did try that and it didn’t help 😞
I’m now trying to figure out how to make sure all my brew packages are native
did you use pip or pip3?
I do believe on macos pip resolves to the 2.7 Python
I think I used pip. Let me make a new venv, run pip3 install --upgrade pip to make sure it’s up to date, then try pip3 install -r requirements.txt (which includes pulumi-digitalocean)
I mean, pip could be pointing to the system python or wrong venv
Check it please
It’s the right venv
And now I can import pulumi
I think the trick was
arch -arm64 brew install python3
That caused the pulumi installation to build the right grpc
And success, I can create a DNS entry. Next step is to tinker with templating to make a cloud-init user data file. Thanks!
Weirdly I just installed python and pulumi via brew and it worked fine on my M1, though I have since found other errors related to Kubernetes and yaml