Closed imarinmed closed 2 years ago
I'm seeing similar issues with zlib on MacOS Big Sur
Workaround for MacOS Big Sur(Intel and Arm) with Python 3.9.0.
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
With GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true I'm now getting different errors related to openssl My Python is installed with the brew openSSL.
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:176:9: warning: 'OPENSSL_VERSION_NUMBER' macro redefined [-Wmacro-redefined]
#define OPENSSL_VERSION_NUMBER 0x1010107f
^
/usr/local/opt/openssl@1.1/include/openssl/opensslv.h:42:10: note: previous definition is here
# define OPENSSL_VERSION_NUMBER 0x1010108fL
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:211:9: warning: 'OPENSSL_EXPORT' macro redefined [-Wmacro-redefined]
#define OPENSSL_EXPORT
^
/usr/local/opt/openssl@1.1/include/openssl/e_os2.h:171:11: note: previous definition is here
# define OPENSSL_EXPORT extern
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:318:13: error: typedef redefinition with different types ('int' vs 'struct crypto_threadid_st')
typedef int CRYPTO_THREADID;
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:231:3: note: previous definition is here
} CRYPTO_THREADID;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:388:29: error: typedef redefinition with different types ('struct ecdsa_sig_st' vs 'struct ECDSA_SIG_st')
typedef struct ecdsa_sig_st ECDSA_SIG;
^
/usr/local/opt/openssl@1.1/include/openssl/ec.h:1127:29: note: previous definition is here
typedef struct ECDSA_SIG_st ECDSA_SIG;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:390:30: error: typedef redefinition with different types ('struct env_md_ctx_st' vs 'struct evp_md_ctx_st')
typedef struct env_md_ctx_st EVP_MD_CTX;
^
/usr/local/opt/openssl@1.1/include/openssl/ossl_typ.h:92:30: note: previous definition is here
typedef struct evp_md_ctx_st EVP_MD_CTX;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:391:26: error: typedef redefinition with different types ('struct env_md_st' vs 'struct evp_md_st')
typedef struct env_md_st EVP_MD;
^
/usr/local/opt/openssl@1.1/include/openssl/ossl_typ.h:91:26: note: previous definition is here
typedef struct evp_md_st EVP_MD;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:395:34: error: typedef redefinition with different types ('struct evp_encode_ctx_st' vs 'struct evp_Encode_Ctx_st')
typedef struct evp_encode_ctx_st EVP_ENCODE_CTX;
^
/usr/local/opt/openssl@1.1/include/openssl/ossl_typ.h:100:34: note: previous definition is here
typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:411:32: error: typedef redefinition with different types ('struct sha256_state_st' vs 'struct SHA256state_st')
typedef struct sha256_state_st SHA256_CTX;
^
/usr/local/opt/openssl@1.1/include/openssl/sha.h:56:3: note: previous definition is here
} SHA256_CTX;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:412:32: error: typedef redefinition with different types ('struct sha512_state_st' vs 'struct SHA512state_st')
typedef struct sha512_state_st SHA512_CTX;
^
/usr/local/opt/openssl@1.1/include/openssl/sha.h:103:3: note: previous definition is here
} SHA512_CTX;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
In file included from third_party/boringssl-with-bazel/src/include/openssl/buf.h:60:
third_party/boringssl-with-bazel/src/include/openssl/base.h:413:29: error: typedef redefinition with different types ('struct sha_state_st' vs 'struct SHAstate_st')
typedef struct sha_state_st SHA_CTX;
^
/usr/local/opt/openssl@1.1/include/openssl/sha.h:39:3: note: previous definition is here
} SHA_CTX;
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:71:8: error: redefinition of 'buf_mem_st'
struct buf_mem_st {
^
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:38:8: note: previous definition is here
struct buf_mem_st {
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:104:22: error: expected parameter declarator
OPENSSL_EXPORT char *BUF_strdup(const char *str);
^
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:31:24: note: expanded from macro 'BUF_strdup'
# define BUF_strdup(s) OPENSSL_strdup(s)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:132:28: note: expanded from macro 'OPENSSL_strdup'
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
^
/usr/local/opt/openssl@1.1/include/openssl/opensslconf.h:133:24: note: expanded from macro 'OPENSSL_FILE'
# define OPENSSL_FILE __FILE__
^
<scratch space>:67:1: note: expanded from here
"third_party/boringssl-with-bazel/src/include/openssl/buf.h"
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:104:22: error: expected ')'
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:31:24: note: expanded from macro 'BUF_strdup'
# define BUF_strdup(s) OPENSSL_strdup(s)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:132:28: note: expanded from macro 'OPENSSL_strdup'
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
^
/usr/local/opt/openssl@1.1/include/openssl/opensslconf.h:133:24: note: expanded from macro 'OPENSSL_FILE'
# define OPENSSL_FILE __FILE__
^
<scratch space>:67:1: note: expanded from here
"third_party/boringssl-with-bazel/src/include/openssl/buf.h"
^
third_party/boringssl-with-bazel/src/include/openssl/buf.h:104:22: note: to match this '('
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:31:24: note: expanded from macro 'BUF_strdup'
# define BUF_strdup(s) OPENSSL_strdup(s)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:132:22: note: expanded from macro 'OPENSSL_strdup'
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:104:22: error: conflicting types for 'CRYPTO_strdup'
OPENSSL_EXPORT char *BUF_strdup(const char *str);
^
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:31:24: note: expanded from macro 'BUF_strdup'
# define BUF_strdup(s) OPENSSL_strdup(s)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:132:9: note: expanded from macro 'OPENSSL_strdup'
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:269:7: note: previous declaration is here
char *CRYPTO_strdup(const char *str, const char *file, int line);
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:110:22: error: expected parameter declarator
OPENSSL_EXPORT char *BUF_strndup(const char *str, size_t size);
^
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:32:31: note: expanded from macro 'BUF_strndup'
# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:134:32: note: expanded from macro 'OPENSSL_strndup'
CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)
^
/usr/local/opt/openssl@1.1/include/openssl/opensslconf.h:133:24: note: expanded from macro 'OPENSSL_FILE'
# define OPENSSL_FILE __FILE__
^
<scratch space>:69:1: note: expanded from here
"third_party/boringssl-with-bazel/src/include/openssl/buf.h"
^
In file included from third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc:138:
third_party/boringssl-with-bazel/src/include/openssl/buf.h:110:22: error: expected ')'
/usr/local/opt/openssl@1.1/include/openssl/buffer.h:32:31: note: expanded from macro 'BUF_strndup'
# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
^
/usr/local/opt/openssl@1.1/include/openssl/crypto.h:134:32: note: expanded from macro 'OPENSSL_strndup'
CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)
^
/usr/local/opt/openssl@1.1/include/openssl/opensslconf.h:133:24: note: expanded from macro 'OPENSSL_FILE'
# define OPENSSL_FILE __FILE__
^
I use openssl with homebrew but I didn't get this error.
@tfcace Do you try to build with GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true
?
Unfortunately, the GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true
approach does not work with us either: Clang continues to complain in the same way. However, you have given me an idea: is there any way we can provide to the pip install grpcio
with the ignores (-Wunused-variable
, -Wnoexceptions-raised
, etc) we would need, at least, to 'build' it?
I am aware that we may end up building a broken grpcio, but if any, this could be interesting in the future as a way to resolve these compilation problems in short-term, while better minds than me solve the issue for long-term...
I haven't tried GRPC_PYTHON_BUILD_SYSTEM_OPENSSL
, I wonder what version of OpenSSL that will build against? The brew one? And if yes, how? I believe I tried brew link for openSSL and MacOS wasn't happy about it.
@tfcace I found the code so I asked you. My case is only "workaround", and it is not "solution".
I am also encountering these errors pertaining to zlib on Mac OS Big Sur. For the time being I was able to get around these build errors by making the following changes in my local zlib files:
lseek
(line 14) to fseek
#include <unistd.h>
after line 6#include <unistd.h>
after line 6This is a workaround and may have un-intended consequences.
@e-simpson Did you just changed those files and pip install grpcio
?
Finally made it work by running:
pip install wheel && GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
I'm very tired now, so to be honest the only thing I did was just copy-pasting every env variable from every issue I found ☺️. Main references: #24248 #24449
Thanks @VagifMammadaliyev - this gave me a huge headache. Your solution finally worked. Hoping the team addresses this.
Wonderful solution, @VagifMammadaliyev! You have really made my day 👍🏼 Beers are on me whenever you visit Berlin! 🍻
Thanks @VagifMammadaliyev for this workaround. This issue was freaking me out from past 2 days and i just came across your workaround and it worked. Once again thanks a lot.
The above didn't work for me for whatever reason but, changing the macos version of the wheel worked for me:
Here i'm using 1.33.2 on cpython 3.8. FOr other versions, check out https://pypi.org/project/grpcio/1.33.2/#files
❯ curl -LOJ "https://files.pythonhosted.org/packages/fb/4d/4b6146ed211a3211231b1253cfeb58818875b5b57a4622602d1b87e16f73/grpcio-1.33.2-cp38-cp38-macosx_10_9_x86_64.whl"
❯ mv grpcio-1.33.2-cp38-cp38-macosx_10_9_x86_64.whl grpcio-1.33.2-cp38-cp38-macosx_11_0_x86_64.whl
❯ pip install grpcio-1.33.2-cp38-cp38-macosx_11_0_x86_64.whl
@VagifMammadaliyev - I introduced another error with GRPC_PYTHON_BUILD_SYSTEM_RE2=true
The following works for me:
GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true
@VagifMammadaliyev you are a hero!
One additional comment - i had to make sure my pip was up to date before the commend in https://github.com/grpc/grpc/issues/24677#issuecomment-729983060 worked for me.
python -m pip install --upgrade pip
For me, all it took was a python -m pip install --upgrade pip
to make it work.
I had a similar issue, my specific case being google-cloud-bigquery
being unable to install grpcio
using pipenv on Big Sur.
A quick fix that worked for me was running
export SYSTEM_VERSION_COMPAT=1
Afterwards, clang errors were no longer thrown and I was able to install grpcio
and google-cloud-bigquery
via pipenv. Not sure if this fix applies to the original issue but hope it helps!
pip install wheel && GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
did not work for the new Mac M1 chip, but was able to download grpc with https://github.com/grpc/grpc/issues/24677#issuecomment-741814641
In the end on the Mac I went with tf-nightly (https://www.tensorflow.org/install). grpcio 1.32.0 bundled with tensorflow 2.4.1 is hard to get working on Big Sur. Whereas 1.34.1 works ok.
pip install wheel && GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
did not work for the new Mac M1 chip, but was able to download grpc with #24677 (comment)
I had similar clang
related problems installing grpcio on mac. In the end I completely reinstalled brew and pyenv using Rosetta terminal (following https://www.reddit.com/r/MacOS/comments/kghwef/best_method_to_install_homebrew_on_m1/), and then installing grpcio worked fine using an up to date version of pip (without needing to set any additional environment variables in the command). Posting in case it helps anyone 👍
Upgrading pip to 21.1.1 solved my issue https://issues.apache.org/jira/browse/ARROW-10744.
On M1 ARM Mac it is possible to run into all kinds of issues. You must not use GNU binary utils or a version of Python built with the GNU binary utils. I had installed Python via pyenv
which used the binary utils installed by homebrew
. In the end here is what worked for me:
brew uninstall binutils
pyenv uninstall 3.9.4
pyenv install 3.9.4
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip3 install grpcio grpcio-tools
The easiest way to know whether you are using the wrong binary utils is to check the output of $(which ranlib) -V
. If you are using the Apple provided binary utils as you should, you will see the following error (which is a good sign):
Apple Inc. version cctools-980
error: /Library/Developer/CommandLineTools/usr/bin/ranlib: no archives specified
Usage: /Library/Developer/CommandLineTools/usr/bin/ranlib [-sactfqLT] [-] archive [...]
Hope this helps someone!
The grpc...true pip 21. upgrade combo worked for me. Big sur. 11.3. M1.
For me:
brew install openssl re2
LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib" CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include" GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
@tongyifan thank you very much, none of the other options worked for me and I figured I was going to have to go down a deep dark LDFLAGS
hole... but you did that for the rest of us
This has been fixed on master and will be included in 1.39.0
, which will be released a week from now.
I'm running this: pip3 install grpcio==1.39.0rc1 --no-cache-dir --force
and still getting failure on M1 (terminal in arm64 mode)
Successfully built grpcio WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages) Installing collected packages: six, grpcio Attempting uninstall: six WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages) Found existing installation: six 1.16.0 Uninstalling six-1.16.0: Successfully uninstalled six-1.16.0 WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages) WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages) Successfully installed grpcio-1.39.0rc1 six-1.16.0 WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages) WARNING: Ignoring invalid distribution -rpcio (/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages)
(env) ~/dev/flask_gcp_py3_datastore$ python Python 3.9.5 | packaged by conda-forge | (default, Jun 19 2021, 00:24:55) [Clang 11.1.0 ] on darwin Type "help", "copyright", "credits" or "license" for more information.
import google.cloud.ndb as ndb Traceback (most recent call last): File "
", line 1, in File "/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/google/cloud/ndb/init.py", line 28, in from google.cloud.ndb.client import Client File "/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/google/cloud/ndb/client.py", line 18, in import grpc File "/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/grpc/init.py", line 23, in from grpc._cython import cygrpc as _cygrpc ImportError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 2): Symbol not found: _CFRelease Referenced from: /opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so Expected in: flat namespace in /opt/homebrew/Caskroom/miniforge/base/envs/env/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so
version 1.39.0rc1 is not working for me
but miniforge has a version that seems to work https://github.com/conda-forge/grpcio-feedstock
@dgaedcke We're looking into the issue you're seeing on M1. Given the time constraints though, the fix will not make it into the 1.39 release.
@tongyifan , Thanks very much. Your solution worked for me.
if doesn't resolved above, try install python 3.9.8 or superior..
@VagifMammadaliyev - I introduced another error with
GRPC_PYTHON_BUILD_SYSTEM_RE2=true
The following works for me:
GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true
thk. @owlas
Closing since this was resolved by the 1.39.0 release, long ago.
Still an issue for me on a M1 mac with Ventura OS. This helped:
env LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" CFLAGS="-I$(brew --prefix openssl@1.1)/include" pip install git+https://github.com/shivaRamdeen/passbook.git
Here's my collection of env variables that finally worked for me on my M2 chip:
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
export GRPC_PYTHON_BUILD_SYSTEM_RE2=1
export SYSTEM_VERSION_COMPAT=1
export LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib"
export CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include"
export CFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include"
export GRPC_BUILD_WITH_BORING_SSL_ASM=""
it's similar to @tongyifan 's answer but I also added re2 to CFLAGS
What version of gRPC and what language are you using?
Several versions of gRPC are used, and this error is reproduced in all of them:
What operating system (Linux, Windows,...) and version?
This problem is observed in both macOS Catalina (10.15.6) and macOS Big Sur (11.0.1).
What runtime / compiler are you using (e.g. python version or version of gcc)
For macOS Catalina:
For macOS Big Sur:
What did you do?
Several approaches, trying to observe or correct the problem itself. It was first discovered when installing
kubemq
, a library that hasgrpcio
as a direct dependency. Then, the problem arises when installing it, either bypoetry
(which uses pip) or directly bypip
:poetry install kubemq
Or directly,poetry install grpcio
This problem evidently arises the same, if usingpip
, as mentioned above.What did you expect to see?
A successful installation of either
kubemq
, orgrpcio
.What did you see instead?
Here is the full error message, plus the stack trace: