I install spacy on a Jupyter notebook Python 3, with Windows 10, and then try to install the English language model.
import spacy
!python -m spacy download en
The latter command givest me the following error:
Traceback (most recent call last):
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\__init__.py", line 12, in <module>
from .cli.info import info as cli_info
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\cli\__init__.py", line 6, in <module>
from .train import train # noqa: F401
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\cli\train.py", line 17, in <module>
from ..gold import GoldCorpus
File "morphology.pxd", line 13, in init spacy.gold
File "vocab.pxd", line 27, in init spacy.morphology
File "vocab.pyx", line 20, in init spacy.vocab
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\lemmatizer.py", line 8, in <module>
from .lookups import Lookups
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\lookups.py", line 6, in <module>
from preshed.bloom import BloomFilter
ModuleNotFoundError: No module named 'preshed.bloom'
What's the preshed.bloom module? Following the answer in this question, I loaded the preshed wheel from this page (preshed‑3.0.2‑cp38‑cp38‑win_amd64.whl), but the problem remains.
Does anyone know how to fix this problem?
This is probably a version mismatch in one of spacy's dependencies. You shouldn't need to download wheels from a third-party site, installing with pip (or conda) should just work.
You can try pip install -U spacy in your current environment to update all the dependencies or if that doesn't help, try installing spacy from scratch in a new virtual environment.
(The answer you linked is a bit out-of-date, but as mentioned in the other answers, spacy only works with 64-bit python, so double-check that, too.)
Related
After I tried to install and register a new virtual environment so I can use it in Jupyter notebook, I ended up with the following problem: any notebook I open or create it displays the error message: "Could not find a kernel matching Python 3. Please select a kernel:"
but there are no kernels registered anymore ...
I couldn't find a good answer although I noticed that many others faced the same problem in the past. Anyone could help?
I am using Ubuntu and pip.
It seems to be a configuration problem with Jupyter.
$ jupyter --paths --debug
JUPYTER_PREFER_ENV_PATH is not set, making the user-level path preferred over the environment-level path for data and config
JUPYTER_NO_CONFIG is not set, so we use the full path list for config
JUPYTER_CONFIG_PATH is not set, so we do not prepend anything to the config paths
JUPYTER_CONFIG_DIR is not set, so we use the default user-level config directory
JUPYTER_PATH is not set, so we do not prepend anything to the data paths
JUPYTER_DATA_DIR is not set, so we use the default user-level data directory
JUPYTER_RUNTIME_DIR is not set, so we use the default runtime directory
config:
/home/florian/.jupyter
/home/florian/..../OCR/ocr_env/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/home/florian/.local/share/jupyter
jupyter kernelspec list
Available kernels:
ocr_env /home/florian/.local/share/jupyter/kernels/ocr_env
python3 /home/florian/.local/share/jupyter/kernels/python3
spark_env /home/florian/.local/share/jupyter/kernels/spark_env
tensorflow /home/florian/.local/share/jupyter/kernels/tensorflow
Another error trying to upgrade pip:
python -m pip install --upgrade pip
Traceback (most recent call last):
File "/home/florian/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/florian/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/__main__.py", line 23, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
from pip._internal.utils.misc import ensure_dir
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 33, in <module>
from pip._internal.locations import (
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/exceptions.py)
Seems I found a solution like this below:
pip3 install --force-reinstall jupyter_client
julia> import Pkg; Pkg.add("IJulia")
julia> using IJulia
julia> IJulia.notebook
💚 ❤️ 💜
Reference:
julia> is running julia.app on macOS
https://github.com/JuliaLang/IJulia.jl/issues/968#issuecomment-739800974
I am trying to load a language model in spaCy, but I get errors when I try to install the model, both in the legacy command and the newer command.
Installing via the legacy shortname:
python -m spacy download en
Traceback (most recent call last):
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 147, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\__init__.py", line 13, in <module>
from . import pipeline # noqa: F401
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\__init__.py", line 1, in <module>
from .attributeruler import AttributeRuler
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\attributeruler.py", line 6, in <module>
from .pipe import Pipe
File "spacy\pipeline\pipe.pyx", line 1, in init spacy.pipeline.pipe
ImportError: DLL load failed while importing strings: The specified module could not be found.
Installing using the newer full name:
python -m spacy download en_core_web_sm
Traceback (most recent call last):
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 147, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\__init__.py", line 13, in <module>
from . import pipeline # noqa: F401
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\__init__.py", line 1, in <module>
from .attributeruler import AttributeRuler
File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\attributeruler.py", line 6, in <module>
from .pipe import Pipe
File "spacy\pipeline\pipe.pyx", line 1, in init spacy.pipeline.pipe
ImportError: DLL load failed while importing strings: The specified module could not be found.
Python 3.9 is installed via anaconda, spaCy v 3.0.6 is installed via pip, and I'm in Windows environment. How can I fix this?
Been facing the same issue, was told problem comes from python3.9 so i tested with 3.8 and this didn't help however installing the following Visual C++ Redistributable solved my problem https://www.microsoft.com/en-in/download/details.aspx?id=48145
I hope that helps!
The issue is not related to particular way you attempt to download models but rather to an issue with loading DLL (pipe.pyx) which is very likely to have a dependency on VS Build Tools that you are missing (see details here).
Once you install this dependency, it should start working.
I found 0 topics about this issue for Windows, only for Ubuntu, MAc etc.
When I try to install any package via Pycharm, e.g. urllib, matplotlib, heidi, I get the exact same error message as below.
Project interpreter is Anaconda Python 3.7.
Any idea how this can solved?
Error: Traceback (most recent call last):
File "E:\Download\PROGIK\Charm Community Edition 2018.3.5\helpers\packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 201, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
from pip.index import Link
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (E:\Download\PROGIK\Anaconda\lib\urllib\request.py)
Edit: with pip I have only problem with matplotlib, which is another topic:
Cannot install matplotlib. Fatal error LNK1181, Visual Studio fail
Simply went into packages folder and deleted matplotlib package manually because could not make it display graphs in Jupyter (didnt try in Pycharm). Trying to reinstall it now, hopefully it will fix the issue.
To install packages whithin anaconda environment under Windows10, you should use "Anaconda prompt" (find it in win menu)
It starts (Base) venv by default and installs packages in it. Therefore using Python interpreter distributed with Anaconda you will be able to import them with no side actions.
Besides matplotlib is installed there by default
I am currently trying to set up spaCy in my system. When I downloaded the module, no errors are being shown. However, upon downloading a language model (specifically, the english one), I got an error. The output is as follows:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "C:\ProgramData\Anaconda3\lib\site-packages\spacy\__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "C:\ProgramData\Anaconda3\lib\site-packages\thinc\__init__.py", line 5, in <module>
import numpy # noqa: F401
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
I have tried reinstalling my spaCy package, but still end up getting the same error. How do I deal with this?
I am using Python 3.7.1. Tried downloading using pip install -U spacy and conda install -c conda-forge spacy. I have also tried validating with python -m spacy validate, and it also returns the same error from above.
Thanks.
Thanks to Ines Montani for pointing this out!
It did seem that a quick reinstallation of numpy helps solve the problem. However, what I did realize is that:
Using pip uninstall numpy and simple pip install numpy solves the problem.
However:
Using conda remove --force numpy and conda install numpy does not solve the problem for me.
It is a tough situation I am dealing with. Here is short version of my problem:
I am working on Ubuntu 12.04
I would like to install Python 3.5.x with openCV library. I would also like to use pip3 for managing package installation of python.
Here is how the version of my pythons looks like
$ python --version
Python 2.7.3
$ python3 --version
Python 3.5.2
So far it looks I have achieved my goal.
When I use virtualenv to manage python3 libraries:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
I see the version of my python as follows:
(py3env)yxxxxa#yxxxxa-Precision-M4800:~$ python3 --version
Python 3.2.3
I seems there is another version of python in my machine 3.2.3 messing up with the version 3.5.2 that I have installed. This is my first problem.
The second related problem is that I am unable to install pip 3. There is this error I receive due to the same python version conflict:
$ pip
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor /pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
yasharatena#yasharatena-Precision-M4800:~$ pip3
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
What are your expert opinions about the stated problem? Any cool idea to handle this? Thanks alot in advance
This solved my first problem. Now the second problem aslo remains, how
can I install pip3 under python 3.5.2 (preferably using viretualenv) ?
Here is answer:
python3 -m virtualenv py3env
source py3env/bin/activate
Python 3.5 should have pip by default, also after above commands You can use pip:)
For example :
python -m pip install requests
EDIT:
Here You could find very good explainations if You still need install pip after create virtualenv.