Fastai2 text spacy import error

I am trying to import fastai2 text, and I am running into a spacy issue. I haven’t been able to find any information on how to resolve, and to be honest I don’t have any idea where to even start. I am reasonably confident it’s an environment issue, as it works on 1 of my computers and not the other.

I have since upgraded fastai2 and spacy to the latest version on both computers, with no change to the abiliity to import on either. I tried force reinstalling packages, which did not resolve anything either.

The one it’s working on is a mac. The one it doesn’t work on is running linux (Pop OS).

Here’s information from the machine it doesn’t work on.

from fastai2.text.all import *

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-ddb56ea520a6> in <module>
----> 1 from fastai2.text.all import *
      2 path = untar_data(URLs.HUMAN_NUMBERS)

~/anaconda3/lib/python3.7/site-packages/fastai2/text/all.py in <module>
      1 from ..basics import *
      2 from ..callback.all import *
----> 3 from .core import *
      4 from .data import *
      5 from .models import *

~/anaconda3/lib/python3.7/site-packages/fastai2/text/core.py in <module>
     13 
     14 # Cell
---> 15 import spacy,html
     16 from spacy.symbols import ORTH
     17 

~/anaconda3/lib/python3.7/site-packages/spacy/__init__.py in <module>
     10 from thinc.neural.util import prefer_gpu, require_gpu
     11 
---> 12 from . import pipeline
     13 from .cli.info import info as cli_info
     14 from .glossary import explain

~/anaconda3/lib/python3.7/site-packages/spacy/pipeline/__init__.py in <module>
      2 from __future__ import unicode_literals
      3 
----> 4 from .pipes import Tagger, DependencyParser, EntityRecognizer, EntityLinker
      5 from .pipes import TextCategorizer, Tensorizer, Pipe, Sentencizer
      6 from .morphologizer import Morphologizer

pipes.pyx in init spacy.pipeline.pipes()

~/anaconda3/lib/python3.7/site-packages/spacy/pipeline/functions.py in <module>
      3 
      4 from ..language import component
----> 5 from ..matcher import Matcher
      6 from ..util import filter_spans
      7 

~/anaconda3/lib/python3.7/site-packages/spacy/matcher/__init__.py in <module>
      3 
      4 from .matcher import Matcher
----> 5 from .phrasematcher import PhraseMatcher
      6 from .dependencymatcher import DependencyMatcher
      7 

phrasematcher.pyx in init spacy.matcher.phrasematcher()

ImportError: preshed.maps does not export expected C function map_clear

Also, I have no idea what most of this below means or whether it relates - but I have seen several people ask for this when debugging so including it in case someone more knowledgeable than I can make sense of it

import os
os.environ

environ{'SHELL': '/bin/bash',
        'SESSION_MANAGER': 'local/pop-os:@/tmp/.ICE-unix/2199,unix/pop-os:/tmp/.ICE-unix/2199',
        'COLORTERM': 'truecolor',
        'XDG_CONFIG_DIRS': '/etc/xdg/xdg-pop:/etc/xdg',
        'XDG_MENU_PREFIX': 'gnome-',
        'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated',
        'GTK_IM_MODULE': 'ibus',
        'CONDA_EXE': '/home/isaacflath/anaconda3/bin/conda',
        '_CE_M': '',
        'LANGUAGE': 'en_US:en',
        'QT4_IM_MODULE': 'ibus',
        'MANDATORY_PATH': '/usr/share/gconf/pop.mandatory.path',
        'LC_ADDRESS': 'en_US.UTF-8',
        'GNOME_SHELL_SESSION_MODE': 'pop',
        'LC_NAME': 'en_US.UTF-8',
        'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh',
        'XMODIFIERS': '@im=ibus',
        'DESKTOP_SESSION': 'pop',
        'LC_MONETARY': 'en_US.UTF-8',
        'SSH_AGENT_PID': '2093',
        'GTK_MODULES': 'gail:atk-bridge:appmenu-gtk-module',
        'PWD': '/home/isaacflath',
        'LOGNAME': 'isaacflath',
        'XDG_SESSION_DESKTOP': 'pop',
        'XDG_SESSION_TYPE': 'x11',
        'CONDA_PREFIX': '/home/isaacflath/anaconda3',
        'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1',
        'XAUTHORITY': '/run/user/1000/gdm/Xauthority',
        'GJS_DEBUG_TOPICS': 'JS ERROR;JS LOG',
        'WINDOWPATH': '2',
        'HOME': '/home/isaacflath',
        'USERNAME': 'isaacflath',
        'IM_CONFIG_PHASE': '1',
        'LC_PAPER': 'en_US.UTF-8',
        'LANG': 'en_US.UTF-8',
        'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:',
        'XDG_CURRENT_DESKTOP': 'pop:GNOME',
        'VTE_VERSION': '5802',
        'CONDA_PROMPT_MODIFIER': '(base) ',
        'GNOME_TERMINAL_SCREEN': '/org/gnome/Terminal/screen/b992ced1_0b87_4434_9cd0_e20cff4c82f3',
        'INVOCATION_ID': '50d2566d98114c0f96b7e976f99f56ef',
        'MANAGERPID': '1965',
        'CLUTTER_IM_MODULE': 'ibus',
        'GJS_DEBUG_OUTPUT': 'stderr',
        'LESSCLOSE': '/usr/bin/lesspipe %s %s',
        'XDG_SESSION_CLASS': 'user',
        'TERM': 'xterm-color',
        'LC_IDENTIFICATION': 'en_US.UTF-8',
        '_CE_CONDA': '',
        'DEFAULTS_PATH': '/usr/share/gconf/pop.default.path',
        'LESSOPEN': '| /usr/bin/lesspipe %s',
        'USER': 'isaacflath',
        'GNOME_TERMINAL_SERVICE': ':1.133',
        'CONDA_SHLVL': '1',
        'DISPLAY': ':1',
        'SHLVL': '1',
        'LC_TELEPHONE': 'en_US.UTF-8',
        'QT_IM_MODULE': 'ibus',
        'LC_MEASUREMENT': 'en_US.UTF-8',
        'PAPERSIZE': 'letter',
        'CONDA_PYTHON_EXE': '/home/isaacflath/anaconda3/bin/python',
        'XDG_RUNTIME_DIR': '/run/user/1000',
        'CONDA_DEFAULT_ENV': 'base',
        'LC_TIME': 'en_US.UTF-8',
        'JOURNAL_STREAM': '9:39785',
        'XDG_DATA_DIRS': '/usr/share/pop:/usr/local/share/:/usr/share/',
        'PATH': '/usr/local/cuda/bin:/home/isaacflath/anaconda3/bin:/home/isaacflath/anaconda3/condabin:$/HOME/terraform:/home/isaacflath/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/isaacflath/.dotnet/tools:/home/isaacflath/DataGrip-2019.3.3/bin:/home/isaacflath/.bashscripts',
        'GDMSESSION': 'pop',
        'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus',
        'LC_NUMERIC': 'en_US.UTF-8',
        'OLDPWD': '/home/isaacflath/github',
        '_': '/home/isaacflath/anaconda3/bin/jupyter',
        'KERNEL_LAUNCH_TIMEOUT': '40',
        'JPY_PARENT_PID': '23774',
        'CLICOLOR': '1',
        'PAGER': 'cat',
        'GIT_PAGER': 'cat',
        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline',
        'KMP_DUPLICATE_LIB_OK': 'True',
        'KMP_INIT_AT_FORK': 'FALSE'}

@Ezno what version of fastai2 is it?

@muellerzr

fastai2.__version__ 

gives me

‘0.0.17’

Now that you got me on that thought, https://pypi.org/project/fastai2/ seems to indicate the latest is 0.0.21.

pip install fastai2 --upgrade

Seems to be thinking that I am on the latest version. I am not really sure why when I import it says 0.0.17, but pip says 0.0.21.

Well I went to dissolve my frustration over ice cream, and when I returned to take another crack at the issue it was fixed. I have no idea what is different now that caused it to start working, but it’s working.

1 Like

I think the solution is obvious! =P

3 Likes

Fair point. I guess I should outline my solution in case anyone else runs across this issue.

1 scoop of Chocolate Brownie Fudge Ice Cream + 1 scoop of Cookies and Cream Icecream + way more whipped cream than I care to admit

1 Like

requirements.txt:

ChocBrownieFudge==1.0
CookiesCream==1.0
WhippedCream>=99.0
2 Likes

LOL! :smiley: :smiley:
HaHa this humor made me laugh!
mrfabulous1 :smiley: :smiley: