when trying to run the code below in jupyter notebook i get an error CODE: ''' cols = 2…
- User
when trying to run the code below in jupyter notebook i get an error
CODE: ''' cols = 2 rows = math.ceil(len(sorted_interesting_tokens) / cols) fig, axes = plt.subplots(rows, cols, figsize=(cols*5, rows*3)) for ix, token in enumerate(sorted_interesting_tokens):
bigram_df = bigram_dfs[token]
t_adf = copy.deepcopy(activation_df.query('token==@token')) t_adf['prefix'] = activation_df.loc[t_adf.index.values - 1, 'token'].values
valid_prefix_tokens = set(bigram_dfs[token].index.values) token_strs = [decoded_vocab[t] for t in valid_prefix_tokens]
ax = axes[ix//2, ix%2] sns.boxplot(t_adf, x='prefix', y='activation', order=bigram_dfs[token].index.values, ax=ax) ax.set_xticklabels([decoded_vocab[int(t.get_text())].replace('', '\') for t in ax.get_xticklabels()], rotation=80); ax.set_title(f'Activations for {token}: "{decoded_vocab[token]}" by preceding token') plt.tight_layout(pad=0) '''
ERROR: ''' /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12290 (\N{IDEOGRAPHIC FULL STOP}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12289 (\N{IDEOGRAPHIC COMMA}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12395 (\N{HIRAGANA LETTER NI}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12394 (\N{HIRAGANA LETTER NA}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12398 (\N{HIRAGANA LETTER NO}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 12356 (\N{HIRAGANA LETTER I}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 20363 (\N{CJK UNIFIED IDEOGRAPH-4F8B}) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 9 ( ) missing from current font. plt.tight_layout(pad=0) /state/partition1/slurm_tmp/22129042.0.0/ipykernel_16294/4186583921.py:20: UserWarning: Glyph 151 (\x97) missing from current font. plt.tight_layout(pad=0) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12290 (\N{IDEOGRAPHIC FULL STOP}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12289 (\N{IDEOGRAPHIC COMMA}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12395 (\N{HIRAGANA LETTER NI}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12394 (\N{HIRAGANA LETTER NA}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12398 (\N{HIRAGANA LETTER NO}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 12356 (\N{HIRAGANA LETTER I}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 20363 (\N{CJK UNIFIED IDEOGRAPH-4F8B}) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 9 ( ) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/events.py:89: UserWarning: Glyph 151 (\x97) missing from current font. func(*args, **kwargs) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 20363 (\N{CJK UNIFIED IDEOGRAPH-4F8B}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12290 (\N{IDEOGRAPHIC FULL STOP}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12289 (\N{IDEOGRAPHIC COMMA}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12395 (\N{HIRAGANA LETTER NI}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12394 (\N{HIRAGANA LETTER NA}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12398 (\N{HIRAGANA LETTER NO}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 12356 (\N{HIRAGANA LETTER I}) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 9 ( ) missing from current font. fig.canvas.print_figure(bytes_io, **kw) /home/gridsan/dtroitskii/sparprob/lib/python3.8/site-packages/IPython/core/pylabtools.py:152: UserWarning: Glyph 151 (\x97) missing from current font. fig.canvas.print_figure(bytes_io, **kw) ''' 451 words 6643 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
The error messages you're encountering are
UserWarnings, which indicate that certain glyphs (characters) are missing from the font that's being used to render the plot. These missing characters include some Unicode characters like IDEOGRAPHIC FULL STOP, IDEOGRAPHIC COMMA, HIRAGANA LETTERS, FULLWIDTH COMMA, and a few others.These warnings do not prevent the code from running, but they might cause issues with the appearance of the plot, such as missing or incorrect characters in the labels.
To resolve this issue, you can try using a different font that supports the missing characters. One way to do this is by using the
matplotliblibrary to set a font family that includes the required glyphs.First, make sure you have a font installed that supports the necessary characters. A popular choice is the "Noto Sans" font family, which you can download from Google Fonts: https://www.google.com/get/noto/
After installing the font, you can update your settings to use the new font. Add the following lines to the beginning of your code:
- User
how can i check if noto is installed on my unix server 12 words 54 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
To check if the "Noto Sans" font is installed on your Unix server, you can search for the font files in the appropriate directories. Font files are typically stored in the following locations:
/usr/share/fonts- System-wide font directory~/.local/share/fonts- User-specific font directory~/.fonts- Another user-specific font directory (less common)
To check if the "Noto Sans" font is installed, you can use the
findcommand to search for the font files in these directories. Open a terminal and run the following command:find /usr/share/fonts ~/.local/share/fonts ~/.fonts -iname "*NotoSans*"This command searches for any file with "NotoSans" in its name within the specified font directories. If the command returns some file paths, it means the "Noto Sans" font is installed on your system.
If the "Noto Sans" font is not installed, you can download and install it manually. Download the font files from Google Fonts (https://www.google.com/get/noto/) and extract the archive. Then, copy the font files (with
.ttfor.otfextensions) to the appropriate font directory, such as or . Make sure to update the font cache by running after installing the font files. - User
how to check if a font family is installed on unix 11 words 50 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
To check if a specific font family is installed on your Unix system, you can use the
fc-listcommand, which is part of thefontconfigpackage. If you don't havefontconfiginstalled, you can install it using your package manager. For example, on Ubuntu or Debian-based systems, you can use the following command:sudo apt-get install fontconfigOnce you have
fontconfiginstalled, you can use thefc-listcommand to list all the installed fonts on your system. To check for a specific font family, you can pipe the output offc-listto thegrepcommand. For example, if you want to check if the "Noto Sans" font family is installed, run the following command:fc-list | grep -i "Noto Sans"This command lists all the installed fonts and filters the output for lines containing "Noto Sans". If you see some output, it means the "Noto Sans" font family is installed on your system.
You can replace "Noto Sans" in the command with the name of the font family you want to check. Be sure to use double quotes if the font family name contains spaces.
- User
i get an error in my jupyter - findfont: Font family 'Noto Sans' not found. 15 words 75 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
The error you are encountering, "findfont: Font family 'Noto Sans' not found," indicates that
matplotlibcannot locate the "Noto Sans" font on your system. To resolve this issue, follow these steps:- Confirm that the "Noto Sans" font is installed on your system by running the following command in your terminal:
fc-list | grep -i "Noto Sans"If the command returns no output, it means the "Noto Sans" font is not installed on your system. In this case, download and install the font as described in a previous answer.
- If the "Noto Sans" font is installed, make sure that
matplotlibis aware of the font. You can do this by updating thematplotlibfont cache:
import matplotlib.font_manager matplotlib.font_manager._rebuild()Run the above code snippet in a Jupyter notebook cell, then restart your Jupyter kernel.
- After updating the font cache, set the "Noto Sans" font family as the default font in
matplotlib. Add the following lines to the beginning of your notebook:
- User
im getting an error AttributeError: module 'matplotlib.font_manager' has no attribute 'rebuild' 12 words 96 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
Apologies for the confusion. It appears I made an error in the code snippet I provided. The correct function to call for rebuilding the font cache in
matplotlibis_rebuild()(with an underscore). Please use the following code snippet in a Jupyter notebook cell:import matplotlib.font_manager matplotlib.font_manager._rebuild()After running this code, restart your Jupyter kernel and set the "Noto Sans" font family as the default font in
matplotlibas described previously:import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams['font.family'] = 'Noto Sans'Now, try running your plot code again. If you still encounter the same error, double-check the font family name in the
fc-listoutput, as it might be slightly different (e.g., 'Noto Sans CJK', 'Noto Sans Display', etc.). Adjust thempl.rcParams['font.family']line accordingly. - User
module 'matplotlib.font_manager' has no attribute '_rebuild' 7 words 61 char Copy Text Copy HTML Export PDF Text-Speech Plagiarism Checker Search Trend Bulgarian Chinese Czech Danish Dutch English (US) English (UK) Estonian Finnish French German Greek Hungarian Indonesian Italian Japanese Latvian Lithuanian Polish Portuguese Portuguese (BZ) Romanian Russian Slovak Slovenian Spanish Swedish Turkish Ukrainian
- Assistant
I apologize for the confusion earlier. It seems that the
_rebuild()method is not available in the version ofmatplotlibyou are using. In this case, you can try rebuilding the font cache by deleting the font cache file and then restarting the Jupyter kernel. The cache file is typically located in your user-specific cache directory.To locate the font cache file, you can use the following Python code:
import matplotlib as mpl print(mpl.get_cachedir())This code will print the cache directory's path. Inside that directory, you should find a file named
fontlist-v310.json(the version number in the file name may vary). Delete this file and restart the Jupyter kernel.After restarting the kernel, try setting the "Noto Sans" font family as the default font in
matplotlibas described previously:import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams['font.family'] = 'Noto Sans'Now, try running your plot code again. If you still encounter the same error, double-check the font family name in the
fc-listoutput, as it might be slightly different (e.g., 'Noto Sans CJK', 'Noto Sans Display', etc.). Adjust thempl.rcParams['font.family']line accordingly.