HyTE 模型复现可能遇到的问题及解决办法

目录

一、ImportError: No module named ' tensorflow '

二、AttributeError: 'version_info' object has no attribute '__version__'。

三、ModuleNotFoundError: No module named 'numpy.testing.decorators'

附录


说明:HyTE 模型 的 Github 地址: 

GitHub - malllabiisc/HyTE: EMNLP 2018: HyTE: Hyperplane-based Temporally aware Knowledge Graph EmbeddingEMNLP 2018: HyTE: Hyperplane-based Temporally aware Knowledge Graph Embedding - GitHub - malllabiisc/HyTE: EMNLP 2018: HyTE: Hyperplane-based Temporally aware Knowledge Graph Embeddinghttps://github.com/malllabiisc/HyTE最好用 conda创建虚拟环境来复现 HyTE模型。另外,在复现时,你首先需要按照上述地址中 readme 的说明来操作。当遇到问题时,再来查看本文试着能否解决自己遇到的问题。


一、ImportError: No module named ' tensorflow '

引起原因:python 版本和 tensorflow 版本不兼容

解决办法:不要重复安装 tensorflowpython 版本,把 pythob 版本降到 3.6 以下

conda install python=3.6

二、AttributeError: 'version_info' object has no attribute '__version__'。

如下图所示:

解决办法:

找到文件:

C:\Users\你的用户名\AppData\Roaming\Python\Python36\site-packages\pyparsing\__init__.py

更改下面的代码段:

class version_info(NamedTuple):
    major: int
    minor: int    
    micro: int
    releaselevel: str
    serial: int

为:

class version_info():
    def __init__(self,major:int,minor:int,micro:int,releaselevel:str,serial:int):   
        self.major = major
        self.minor = minor
        self.micro = micro
        self.releaselevel = releaselevel
        self.serial = serial

三、ModuleNotFoundError: No module named 'numpy.testing.decorators'

如下图所示:

解决步骤:

(a)卸载原有 numpy

多次执行命令:

pip uninstall numpy

直到所有版本都被卸载(即出现命令 WARNING: Skipping numpy as it is not installed.): 

(b)安装 numpy

pip3 install numpy==1.16.4

注意要安装 numpy==1.17.0 以下的版本,否则报以下警告:

FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.

如下图所示: 


 当然,第三节这个问题还有一种解决方案,可以参考下面这一篇博客:

【不降级的解决方案】ModuleNotFoundError: No module named ‘numpy.testing.decorators‘_link_in_csdn的博客-CSDN博客使用Python的numpy包时,如果有涉及到对numpy.testing.decorators的引入,可能会报错ModuleNotFoundError: No module named 'numpy.testing.decorators'。目前能搜到的大多数教程都是建议大家降级,这是不明智的做法,本文介绍了该问题产生的底层原因,并且分类讨论了对应的解决办法https://blog.csdn.net/link_in_csdn/article/details/124815024


四、UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 423: illegal multibyte sequence

处理办法:在 time_proj.py 中关于文件的操作加入 encoding="utf-8"


附录

安装 numpy 还可能遇到的问题 :

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
mkl-random 1.0.1 requires cython, which is not installed.

执行以下命令:

pip install --upgrade setuptools
pip install mkl-random

如下图所示:

猜你喜欢

转载自blog.csdn.net/qq_40506723/article/details/127296754