我正在尝试this open-source library from GitHub called talon从与工作相关的项目的电子邮件签名中提取重要信息,并且似乎被“ Not A Directory”错误所困扰。自从我使用Python已有很长时间了,所以请多多包涵。
这是我要运行的使用talon模块的示例脚本,称为test.py
:
import talon
from talon import quotations
talon.init()
text = """Reply
-----Original Message-----
Quote"""
reply = quotations.extract_from(text, 'text/plain')
reply = quotations.extract_from_plain(text)
在使用Python 2.7.11到python test.py
运行此命令时,出现以下错误输出:
Traceback (most recent call last):
File "test.py", line 4, in <module>
talon.init()
File "build/bdist.macosx-10.11-x86_64/egg/talon/__init__.py", line 13, in init
File "build/bdist.macosx-10.11-x86_64/egg/talon/signature/__init__.py", line 39, in initialize
File "build/bdist.macosx-10.11-x86_64/egg/talon/signature/learning/classifier.py", line 34, in load
File "/usr/local/lib/python2.7/site-packages/scikit_learn-0.20.0-py2.7-macosx-10.11-x86_64.egg/sklearn/externals/joblib/numpy_pickle.py", line 590, in load
with open(filename, 'rb') as f:
我做了同样的事情,但是用Python 3.7.1代替,我得到了类似的错误:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scikit_learn-0.20.0-py3.7-macosx-10.9-x86_64.egg/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/learning/classifier.py", line 34, in load
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scikit_learn-0.20.0-py3.7-macosx-10.9-x86_64.egg/sklearn/externals/joblib/numpy_pickle.py", line 590, in load
with open(filename, 'rb') as f:
NotADirectoryError: [Errno 20] Not a directory: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/data/classifier'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 4, in <module>
talon.init()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/__init__.py", line 13, in init
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/__init__.py", line 39, in initialize
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/learning/classifier.py", line 38, in load
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/learning/classifier.py", line 50, in load_compat
NotADirectoryError: [Errno 20] Not a directory: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/talon-1.4.5-py3.7.egg/talon/signature/data'
有人遇到过和我一样的问题吗?否则,我该怎么办?
我认为我主要在包含我安装的talon存储库的目录中使用sudo python setup.py install
,因为我的工作帐户不允许我在没有root级访问权限的情况下自行安装Python库。 / p>
编辑:有人向我指出了pip install talon
。
这是使用--user
选项运行上述命令的输出:
Requirement already satisfied (use --upgrade to upgrade): talon in /usr/local/lib/python2.7/site-packages/talon-1.4.5-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): lxml>=2.3.3 in /usr/local/lib/python2.7/site-packages/lxml-4.2.5-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): regex>=1 in /usr/local/lib/python2.7/site-packages/regex-2018.8.29-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/site-packages (from talon)
Requirement already satisfied (use --upgrade to upgrade): scipy in /usr/local/lib/python2.7/site-packages (from talon)
Requirement already satisfied (use --upgrade to upgrade): scikit-learn>=0.16.1 in /usr/local/lib/python2.7/site-packages/scikit_learn-0.20.0-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): chardet>=1.0.1 in /usr/local/lib/python2.7/site-packages/chardet-3.0.4-py2.7.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): cchardet>=0.3.5 in /usr/local/lib/python2.7/site-packages/cchardet-2.1.4-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): cssselect in /usr/local/lib/python2.7/site-packages/cssselect-1.0.3-py2.7.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /Library/Python/2.7/site-packages (from talon)
Requirement already satisfied (use --upgrade to upgrade): html5lib in /usr/local/lib/python2.7/site-packages/html5lib-1.0.1-py2.7.egg (from talon)
Requirement already satisfied (use --upgrade to upgrade): webencodings in /usr/local/lib/python2.7/site-packages/webencodings-0.5.1-py2.7.egg (from html5lib->talon)
You are using pip version 8.1.2, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
这是使用--upgrade
标志的输出:
Requirement already up-to-date: talon in /usr/local/lib/python2.7/site-packages/talon-1.4.5-py2.7.egg
Requirement already up-to-date: lxml>=2.3.3 in /usr/local/lib/python2.7/site-packages/lxml-4.2.5-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already up-to-date: regex>=1 in /usr/local/lib/python2.7/site-packages/regex-2018.8.29-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already up-to-date: numpy in /usr/local/lib/python2.7/site-packages (from talon)
Requirement already up-to-date: scipy in /usr/local/lib/python2.7/site-packages (from talon)
Requirement already up-to-date: scikit-learn>=0.16.1 in /usr/local/lib/python2.7/site-packages/scikit_learn-0.20.0-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already up-to-date: chardet>=1.0.1 in /usr/local/lib/python2.7/site-packages/chardet-3.0.4-py2.7.egg (from talon)
Requirement already up-to-date: cchardet>=0.3.5 in /usr/local/lib/python2.7/site-packages/cchardet-2.1.4-py2.7-macosx-10.11-x86_64.egg (from talon)
Requirement already up-to-date: cssselect in /usr/local/lib/python2.7/site-packages/cssselect-1.0.3-py2.7.egg (from talon)
Collecting six>=1.10.0 (from talon)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Requirement already up-to-date: html5lib in /usr/local/lib/python2.7/site-packages/html5lib-1.0.1-py2.7.egg (from talon)
Requirement already up-to-date: webencodings in /usr/local/lib/python2.7/site-packages/webencodings-0.5.1-py2.7.egg (from html5lib->talon)
Installing collected packages: six
Successfully installed six-1.10.0
不幸的是,这与上面的问题没有区别。