Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: symbol not found in flat namespace (protobuf 3.20.2) #10571

Closed
pietrodn opened this issue Sep 14, 2022 · 28 comments · Fixed by streamlit/streamlit#5478
Closed

ImportError: symbol not found in flat namespace (protobuf 3.20.2) #10571

pietrodn opened this issue Sep 14, 2022 · 28 comments · Fixed by streamlit/streamlit#5478

Comments

@pietrodn
Copy link

pietrodn commented Sep 14, 2022

What version of protobuf and what language are you using?
Python, protobuf==3.20.2

What operating system (Linux, Windows, ...) and version?
macOS 12.6

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.10.6

What did you do?

python3 -m venv venv
. venv/bin/activate
pip install protobuf==3.20.2
python3 -c "import google.protobuf.descriptor"

What did you expect to see
Nothing (a successful import)

What did you see instead?

>>> import google.protobuf.descriptor
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: dlopen(.venv/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (__ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_)

FYI a similar error is happening inside Google's google-cloud-bigquery library.

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

  1. The issue does not happen in a Linux environment (our CI).
  2. The issue does not happen with protobuf==3.20.1.
  3. The issue does not happen on Python 3.8.
@pietrodn pietrodn added the untriaged auto added to all issues by default when created. label Sep 14, 2022
@pietrodn pietrodn changed the title ImportError ImportError: symbol not found in flat namespace (protobuf 3.20.2) Sep 14, 2022
@jcrm1
Copy link

jcrm1 commented Sep 15, 2022

Also getting this error (still on macOS 12.6, Python 3.10.6)

@madsjk816
Copy link

+1 here, macOS 12.6, Python 3.10.6, protobuf==3.20.2 and Mac M1

@miohtama
Copy link

miohtama commented Sep 15, 2022

Same: macOS 12.6, Python 3.10.6, protobuf==3.20.2 and Mac M1.

For me, I am not using even using Protobuf, but one of the dependencies imports it on a startup and this side effect causes the codebase no longer run:

    from ethpm.dependencies import (
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
    exec(co, module.__dict__)
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/ethpm/dependencies.py", line 7, in <module>
    from ethpm.validation.package import (
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
    exec(co, module.__dict__)
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/ethpm/validation/package.py", line 11, in <module>
    from ethpm._utils.ipfs import (
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
    exec(co, module.__dict__)
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/ethpm/_utils/ipfs.py", line 18, in <module>
    from google.protobuf.descriptor import (
  File "/Users/moo/Library/Caches/pypoetry/virtualenvs/backend-WPuQnUi4-py3.10/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message

@miohtama
Copy link

Confirming downgrade works:

  • Updating protobuf (3.20.2 -> 3.20.1)

@fowles fowles added python packaging & distribution and removed untriaged auto added to all issues by default when created. labels Sep 15, 2022
@cinnil
Copy link

cinnil commented Sep 15, 2022

Had this same issue pop up while installing lstein/stable-diffusion and downgrading solved it as well. Thanks!

Confirming downgrade works:

  • Updating protobuf (3.20.2 -> 3.20.1)

@AlexSchultz-clumio
Copy link

3.19.5 also suffers from the same issue. Downgrading to 3.19.4 works.

@nikiz24
Copy link

nikiz24 commented Sep 16, 2022

in my case
brew install protobuf
brew link --overwrite protobuf
works. Others like downgrade pip protobuf does not work for me.

1 similar comment
@nikiz24
Copy link

nikiz24 commented Sep 16, 2022

in my case
brew install protobuf
brew link --overwrite protobuf
works. Others like downgrade pip protobuf does not work for me.

@scomma
Copy link

scomma commented Sep 16, 2022

3.19.5 also suffers from the same issue. Downgrading to 3.19.4 works.

Confirmed fix, thanks! Came here trying to install stable diffuser.

@bh2smith
Copy link

Issue also doesn't happen on python 3.9!

@Ported
Copy link

Ported commented Sep 16, 2022

Running "pip install protobuf==3.19.4" to downgrade also worked for me.

@pro0517
Copy link

pro0517 commented Sep 21, 2022

+1 here, macOS 11.2, Python 3.10.7, protobuf==3.20.2 and Mac M1

@lightnessofbein
Copy link

I used to have troubles with protobuf==3.20.2 (ImportError cause by some symbols) right after import feast
Downgrading to 3.20.1 solves the problem

@Roymprog
Copy link

Roymprog commented Sep 22, 2022

I do experience the same problem with Python version 3.8.13 using poetry. Perhaps it's related to this issue.
Neither version 3.20.1 nor 3.19.4 seems to work.

I have found that protobuf-3.20.1-py2.py3-none-any.whl fails, and protobuf-3.20.1-cp38-cp38-macosx_10_9_x86_64.whl works.

EDIT:
Solved my issue by being explicit about how to build protobuf on M1 Mac:
pip install protobuf==3.20 --install-option="--cpp_implementation"

@pietrodn
Copy link
Author

pietrodn commented Oct 3, 2022

It appears that the same bug was introduced in parallel in 3.19.5 and 3.20.2, most likely as a result of backporting some bug fix to the earlier minor revision.

@deannagarcia
Copy link
Member

Sorry about this issue. The problem is that the 3.19 and 3.20 branches only used the pure python implementation of protobuf. The newest update has added an incomplete C++ implementation for M1 binaries which has caused the crash.

To work around, you can set the environment variable PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python.

We are working on a fix now, but in order to get the most efficient python implementation we would recommend you upgrade to protobuf 4.21.7.

@deannagarcia
Copy link
Member

I believe this issue should be fixed for 3.19.5, 3.19.6, 3.20.2, and 3.20.3. Please let me know if you are still experiencing issues.

The fix will force python 3.10 osx users to use pure python. If performance is important to you, we highly recommend you upgrade to 4.21.7.

@pietrodn
Copy link
Author

pietrodn commented Oct 4, 2022

I confirm the issue is fixed for 3.19.5, 3.19.6, 3.20.2, and 3.20.3 on Python 3.10.6, macOS 12.6, M1 Pro processor. 😄

Thank you!

fselmo added a commit to fselmo/web3.py that referenced this issue Oct 4, 2022
- Start from ``3.10.2`` since a security vulnerability was fixed there: GHSA-8gq9-2x98-w8hf
- Discussion here: protocolbuffers/protobuf#10571
fselmo added a commit to fselmo/web3.py that referenced this issue Oct 4, 2022
- Start from ``3.20.2`` since a security vulnerability was fixed there: GHSA-8gq9-2x98-w8hf
- Discussion here: protocolbuffers/protobuf#10571
@nmariz
Copy link

nmariz commented Oct 10, 2022

I confirm the issue is fixed for 3.19.5, 3.19.6, 3.20.2, and 3.20.3 on Python 3.10.6, macOS 12.6, M1 Pro processor. 😄

No it's not.

$ python --version
Python 3.10.3

$ python -c "import google.protobuf; print(google.protobuf.__version__)"
3.20.3

$ python -c "import google.protobuf.descriptor"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/nmariz/tmp/venv/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: dlopen(/Users/nmariz/tmp/venv/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (__ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_)

And upgrading to 4.21.7 is not a workable solution, since the stubs are incompatible with 3.x. As well as the environment variable, specially for libraries that use Protobuf. I don't get it why the bug is closed and not fixed. Basically all macOS users will have to use a release with a known security issue (in the 3.20 series).

@pietrodn
Copy link
Author

@nmariz, somehow the import works perfectly on my Mac with Python 3.10.6 and Protobuf 3.20.3. Very weird. 🤔

@deannagarcia deannagarcia reopened this Oct 10, 2022
@deannagarcia
Copy link
Member

Sorry you're still seeing this issue, I thought it was resolved.

I was able to reproduce with the steps in the original bug and after my change the error went away. When you use those steps are you still seeing the error?

Can you provide reproduction steps that include installing protobuf? Have you uninstalled/reinstalled?

@nmariz
Copy link

nmariz commented Oct 10, 2022

Thanks for considering my comment, but please ignore it.
Indeed it doesn't raise the error now, because I was using a binary version with the C extension, that I've installed with pip. I think you've yanked that package from PyPI and it's not available anymore, so for macOS ARM64 only the pure Python is available.

tintinthong added a commit to cardstack/cardstack that referenced this issue Oct 14, 2022
tintinthong added a commit to cardstack/cardstack that referenced this issue Oct 25, 2022
tintinthong added a commit to cardstack/cardstack that referenced this issue Oct 25, 2022
* update to get list of tasks from parameters

* upgrade protobuf protocolbuffers/protobuf#10571

* remove write_parameters_file. We are using metadata

* remove json

* update launch for testing

* update flat payment parameters

* update generic rule

* add pydash

* update main run

* update payment tree to add column

* update flat payment

* get scheduler to flatten explanation block into parameters

* rename run_reward_program to run_task

* clean

* fix to have default for explanation_data_arr

* fix rollover test

* fix safe ownership test

* fix retro airdrop test

* fix staking test

* fix flat payment test

* fix add metadata test

* remove unused import lint

* update input parameters

* update staking

* remove explanation_id argument from as_arrow

* make explanationData part of payment

* remove explanation id and explanation block from rule
tintinthong added a commit to cardstack/cardstack that referenced this issue Oct 25, 2022
* update to get list of tasks from parameters

* upgrade protobuf protocolbuffers/protobuf#10571

* remove write_parameters_file. We are using metadata

* remove json

* update launch for testing

* update flat payment parameters

* update generic rule

* add pydash

* update main run

* update payment tree to add column

* update flat payment

* get scheduler to flatten explanation block into parameters

* rename run_reward_program to run_task

* clean

* fix to have default for explanation_data_arr

* fix rollover test

* fix safe ownership test

* fix retro airdrop test

* fix staking test

* fix flat payment test

* fix add metadata test

* remove unused import lint

* update input parameters

* update staking

* remove explanation_id argument from as_arrow

* make explanationData part of payment

* remove explanation id and explanation block from rule

* update generic rule

* add rollover_amount to explanation

* fix rollover test

* remove group_by import

* add explanation for staking

* fix black

* fix staking rule

* fix merge

* remove group_by function

* Update indexer and api to use explanation (#3352)

* update generic rule

* update idnexer

* update flat_drop script

* update api

* add laucnh files for debugging

* update flat payment params

* fix

* remove setuptools

* just trigger

* update parquet files for test

* update staking params

* add deafaults for files with no explanationId or explanationData

* fix reward api project toml

* add name and version fro indexer

* fix merge

* remove itertools import
@marinagalenko
Copy link

Hello!
Not sure if I should comment here since the issue is closed, but I'm experiencing the same issue.

sw_vers
ProductName:		macOS
ProductVersion:		13.0.1
BuildVersion:		22A400

python --version
Python 3.10.7

python -c "import google.protobuf; print(google.protobuf.__version__)"
3.20.3

python -c "import google.protobuf.descriptor"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/marina.galenko/Documents/GSL/hudl-videospa/tests/ui/venv/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: dlopen(/Users/marina.galenko/Documents/GSL/hudl-videospa/tests/ui/venv/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_'

@fabiogra
Copy link

fabiogra commented May 4, 2023

I solved downgrading Python to 3.9.16 (Apple M1 macOS 12.6)

Python 3.9.16 (main, Mar  8 2023, 04:29:24) 
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin

>>> import google.protobuf; print(google.protobuf.__version__)
3.20.3
>>> import google.protobuf.descriptor
>>> 

mattstern31 added a commit to mattstern31/imagin-AIry-Python that referenced this issue Nov 11, 2023
- add url init images
- don't install protobuf versions that are causing problems
brycedrennan/imaginAIry#7
protocolbuffers/protobuf#10571
superlucky19971023 added a commit to superlucky19971023/imaginAIry that referenced this issue Aug 18, 2024
- add url init images
- don't install protobuf versions that are causing problems
brycedrennan/imaginAIry#7
protocolbuffers/protobuf#10571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.