[英]Getting ModuleNotFoundError (No module named 'pkg_resources.extern') while importing spacy
I'm getting module not found error while importing spacy in my jupyter notebook.在我的 jupyter 笔记本中导入 spacy 时出现模块未找到错误。
ModuleNotFoundError: (No module named 'pkg_resources.extern') ModuleNotFoundError: (没有名为“pkg_resources.extern”的模块)
Full error log here:完整的错误日志在这里:
ModuleNotFoundError Traceback (most recent call last)
in ()
→ 278 import spacy
279 import logging
280
/python/spacy/2.1.4-py37/exec/lib/spacy/init.py in ()
10 from thinc.neural.util import prefer_gpu, require_gpu
11
—> 12 from .cli.info import info as cli_info
13 from .glossary import explain
14 from .about import version
/python/PROJ/spacy/2.1.4-py37/exec/lib/spacy/cli/init.py in ()
----> 1 from .download import download
/python/PROJ/spacy/2.1.4-py37/exec/lib/spacy/cli/download.py in ()
9 from wasabi import Printer
10
—> 11 from .link import link
12 from …util import get_package_path
13 from … import about
/python/PROJ/spacy/2.1.4-py37/exec/lib/spacy/cli/link.py in ()
7
8 from …compat import symlink_to, path2str
----> 9 from … import util
10
11
/python/PROJ/spacy/2.1.4-py37/exec/lib/spacy/util.py in ()
3
4 import os
----> 5 import pkg_resources
6 import importlib
7 import re
/user/rahul/.local/lib/python3.7/site-packages/pkg_resources/init.py in ()
55 FileExistsError = OSError
56
—> 57 from pkg_resources.extern import six
58 from pkg_resources.extern.six.moves import urllib, map, filter
59
ModuleNotFoundError: No module named ‘pkg_resources.extern’
I followed multiple posts on the similar error and tried reinstalling/upgrading setuptools/pkg_resources, but none of them resolved my issue.我关注了多个关于类似错误的帖子,并尝试重新安装/升级 setuptools/pkg_resources,但没有一个解决了我的问题。 This is happening only at my local!
这只发生在我的本地! Also, note that this is happening only with spacy, but the error is pointing to python package
pkg_resources
.另外,请注意,这仅在 spacy 中发生,但错误指向 python 包
pkg_resources
。 I'm stuck with this issue for quite long now, any suggestions would be highly apricated.我已经被这个问题困扰了很长时间,任何建议都将受到高度评价。 Thanks in advance!
提前致谢!
I think in python 3 pkg_resources/__init__.py
should not contain line from pkg_resources.extern import six
- this is python 2 related.我认为在 python 3
pkg_resources/__init__.py
不应该包含from pkg_resources.extern import six
- 这是与 python 2 相关的。 Somehow you have an older version of setuptools
targeted at python 2. I suggest you trying to install specific setuptools
version, eg pip install setuptools==56.0.0
.不知何故,您有一个针对 python 2 的旧版
setuptools
。我建议您尝试安装特定的setuptools
版本,例如pip install setuptools==56.0.0
。
I fixed the issue by deleting the .local
, .jupyter
& .ipython
directories from my user home directory.我通过从我的用户主目录中删除
.local
、 .jupyter
和.ipython
目录来解决这个问题。 The issue went away right after deleting the corrupted local files/directories.删除损坏的本地文件/目录后,问题立即消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.