-
Notifications
You must be signed in to change notification settings - Fork 784
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
cannot import name 'Mapping' from 'collections' #119
Comments
Just as a note, this happens with Python 3.10 as well. From what I can see, this has to do with urllib3 and requests, which seem to contain the offending code. (Meaning, the imports should be from |
Hi @jeffnyman and @paulaceccon, thanks for the issue and apologies for the late reply. I can't seem to replicate the error with python 3.10 or 3.11. How did you install BertViz? Thanks! |
In my case, I'm using Poetry, so I did:
It definitely installs without a problem and I can use it. But when using the BertModel, it looks like requests and urllib3 were referenced specifically as using the older import for collections. So I wasn't sure if this was related to the versions that BertViz was using. I did try adding both directly:
But that still seemed to show the issue. I'll create an entirely new environment and see if I can replicate. I'll include the stack trace as well. |
@jessevig I can definitely recreate on a fully new environment, on either Windows or Mac. Here is the script I'm running on Python 3.10.11 and Python 3.11.4: from transformers import AutoTokenizer
from bertviz.transformers_neuron_view import BertModel
from bertviz.neuron_view import show
model_checkpoint = "bert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = BertModel.from_pretrained(model_checkpoint)
text = "a crane flew over the serene lake"
show(model, "bert", tokenizer, text, display_mode="light", layer=0, head=8) Here is the stack trace:
In looking at this, I now see it looks to be vendored versions of the dependencies that If you drop down to Python 3.9, everything is fine. |
Thanks so much for the detailed analysis @jeffnyman! I will take a look at this. |
I manually added botocore to be the newest version (1.34.6) and it fixed the problem. The problem is in that botocore brings its own dependencies with it in the "vendored" subdirectory. |
I'm getting this error when calling:
With Python 3.11. The
Mapping
location has been updated but this is not reflected here.The text was updated successfully, but these errors were encountered: