我正在使用magpie-具有Word2vec的Tensorflow上的多标签分类器。使用Python 2.7可以很好地进行培训,但是使用Python 3.x可以在下面给出此错误。我在Ubuntu 16.04.5 LTS上,奇怪的是Python 3.x代码在另一台Ubuntu计算机上可以正常工作。我已经更新了我的依赖项:word2vec,喜p,tf,并且不确定出什么问题。
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
Using TensorFlow backend.
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
Traceback (most recent call last):
File "train_magpie.py", line 1, in <module>
from magpie import Magpie
File "/usr/local/lib/python3.5/dist-packages/magpie/__init__.py", line 1, in <module>
from .main import Magpie
File "/usr/local/lib/python3.5/dist-packages/magpie/main.py", line 12, in <module>
from magpie.base.word2vec import train_word2vec, fit_scaler
File "/usr/local/lib/python3.5/dist-packages/magpie/base/word2vec.py", line 7, in <module>
from gensim.models import Word2Vec
File "/usr/local/lib/python3.5/dist-packages/gensim/__init__.py", line 6, in <module>
from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
File "/usr/local/lib/python3.5/dist-packages/gensim/parsing/__init__.py", line 7, in <module>
from .preprocessing import *
File "/usr/local/lib/python3.5/dist-packages/gensim/parsing/preprocessing.py", line 10, in <module>
from gensim import utils
File "/usr/local/lib/python3.5/dist-packages/gensim/utils.py", line 50, in <module>
from smart_open import smart_open
File "/usr/local/lib/python3.5/dist-packages/smart_open/__init__.py", line 1, in <module>
from .smart_open_lib import *
File "/usr/local/lib/python3.5/dist-packages/smart_open/smart_open_lib.py", line 45, in <module>
from boto.compat import BytesIO, urlsplit, six
File "/usr/lib/python3/dist-packages/boto/__init__.py", line 1216, in <module>
boto.plugin.load_plugins(config)
File "/usr/lib/python3/dist-packages/boto/plugin.py", line 92, in load_plugins
for file in glob.glob(os.path.join(directory, '*.py')):
File "/usr/lib/python3.5/posixpath.py", line 89, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
答案 0 :(得分:1)
该异常来自boto/plugin.py
。由于某种原因,它获取None
而不是某个目录名的字符串,然后尝试对None
下的所有文件进行全局设置,该操作失败,因为您无法os.path.join
处于全局模式到None
。
那么,为什么要这么做呢?
最有可能的是,您的boto插件目录中存在一些垃圾。或者,如果不存在,则在您的配置中。 (如果boto在这种情况下具有更好的错误处理能力,那很好,但它可能不会经常出现……)
很有可能只是卸载并重新安装Boto插件即可解决。
对于以后阅读此书的任何人:
如果您的例外情况以此结尾(可能不同的行号和版本号除外):
File "/usr/lib/python3/dist-packages/boto/__init__.py", line 1216, in <module>
boto.plugin.load_plugins(config)
File "/usr/lib/python3/dist-packages/boto/plugin.py", line 92, in load_plugins
for file in glob.glob(os.path.join(directory, '*.py')):
File "/usr/lib/python3.5/posixpath.py", line 89, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
...这是相同的错误。但是,如果重新安装boto插件无济于事,则需要创建一个新问题。 (并包括在插件目录中调用find
或tree
的结果,配置文件的内容以及所有相关的版本号。)