ModuleNotFoundError:当我在Colab中安装ELMo时,没有名为“ elmoformanylangs”的模块

时间:2019-10-16 09:34:59

标签: google-colaboratory elmo

我按照以下步骤安装ELMoForManyLangs

! git clone https://github.com/HIT-SCIR/ELMoForManyLangs.git

cd ELMoForManyLangs/

! python setup.py install

from elmoformanylangs import Embedder

  
    
      
        

ModuleNotFoundError追溯(最近一次通话)

                 

in()

                 

----> 1从elmoformanylangs导入Embedder

                 

2#e = Embedder('./ zhs.model /')

      
    
  

但是我确实成功部署了它。


    running install
    running bdist_egg
    running egg_info
    creating elmoformanylangs.egg-info
    writing elmoformanylangs.egg-info/PKG-INFO
    writing dependency_links to elmoformanylangs.egg-info/dependency_links.txt
    writing requirements to elmoformanylangs.egg-info/requires.txt
    writing top-level names to elmoformanylangs.egg-info/top_level.txt
    writing manifest file 'elmoformanylangs.egg-info/SOURCES.txt'
    writing manifest file 'elmoformanylangs.egg-info/SOURCES.txt'
    installing library code to build/bdist.linux-x86_64/egg
    running install_lib
    running build_py
    creating build
    creating build/lib
    creating build/lib/elmoformanylangs
    copying elmoformanylangs/biLM.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/__init__.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/__main__.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/utils.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/elmo.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/dataloader.py -> build/lib/elmoformanylangs
    copying elmoformanylangs/frontend.py -> build/lib/elmoformanylangs
    creating build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/lstm_cell_with_projection.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/encoder_base.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/embedding_layer.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/lstm.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/__init__.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/util.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/classify_layer.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/token_embedder.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/elmo.py -> build/lib/elmoformanylangs/modules
    copying elmoformanylangs/modules/highway.py -> build/lib/elmoformanylangs/modules
    creating build/bdist.linux-x86_64
    creating build/bdist.linux-x86_64/egg
    creating build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/biLM.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/__init__.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/__main__.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/utils.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/elmo.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    creating build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/lstm_cell_with_projection.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/encoder_base.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/embedding_layer.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/lstm.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/__init__.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/util.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/classify_layer.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/token_embedder.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/elmo.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/modules/highway.py -> build/bdist.linux-x86_64/egg/elmoformanylangs/modules
    copying build/lib/elmoformanylangs/dataloader.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    copying build/lib/elmoformanylangs/frontend.py -> build/bdist.linux-x86_64/egg/elmoformanylangs
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/biLM.py to biLM.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/__init__.py to __init__.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/__main__.py to __main__.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/utils.py to utils.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/elmo.py to elmo.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/lstm_cell_with_projection.py to lstm_cell_with_projection.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/encoder_base.py to encoder_base.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/embedding_layer.py to embedding_layer.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/lstm.py to lstm.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/__init__.py to __init__.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/util.py to util.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/classify_layer.py to classify_layer.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/token_embedder.py to token_embedder.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/elmo.py to elmo.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/modules/highway.py to highway.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/dataloader.py to dataloader.cpython-36.pyc
    byte-compiling build/bdist.linux-x86_64/egg/elmoformanylangs/frontend.py to frontend.cpython-36.pyc
    creating build/bdist.linux-x86_64/egg/EGG-INFO
    copying elmoformanylangs.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying elmoformanylangs.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying elmoformanylangs.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying elmoformanylangs.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying elmoformanylangs.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    zip_safe flag not set; analyzing archive contents...
    creating dist
    creating 'dist/elmoformanylangs-0.0.2-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
    removing 'build/bdist.linux-x86_64/egg' (and everything under it)
    Processing elmoformanylangs-0.0.2-py3.6.egg
    Copying elmoformanylangs-0.0.2-py3.6.egg to /usr/local/lib/python3.6/dist-packages
    Adding elmoformanylangs 0.0.2 to easy-install.pth file

    Installed /usr/local/lib/python3.6/dist-packages/elmoformanylangs-0.0.2-py3.6.egg
    Processing dependencies for elmoformanylangs==0.0.2
    Searching for overrides
    Reading https://pypi.org/simple/overrides/
    Downloading https://files.pythonhosted.org/packages/7a/b2/2cb6a3fc8ee1dc8617e07e476be19723748ddfcce0c6b9db7a5f2d5b9598/overrides-2.0.tar.gz#sha256=63293d9b03629507396ddd961bd5773f136d602f34b9b3da93351dfa163fc0d9
    Best match: overrides 2.0
    Processing overrides-2.0.tar.gz
    Writing /tmp/easy_install-_c47zox2/overrides-2.0/setup.cfg
    Running overrides-2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_c47zox2/overrides-2.0/egg-dist-tmp-677wh9fn
    zip_safe flag not set; analyzing archive contents...
    Moving overrides-2.0-py3.6.egg to /usr/local/lib/python3.6/dist-packages
    Adding overrides 2.0 to easy-install.pth file

    Installed /usr/local/lib/python3.6/dist-packages/overrides-2.0-py3.6.egg
    Searching for numpy==1.17.2
    Best match: numpy 1.17.2
    Adding numpy 1.17.2 to easy-install.pth file
    Installing f2py script to /usr/local/bin
    Installing f2py3 script to /usr/local/bin
    Installing f2py3.6 script to /usr/local/bin

    Using /tensorflow-2.0.0-rc2/python3.6
    Searching for h5py==2.10.0
    Best match: h5py 2.10.0
    Adding h5py 2.10.0 to easy-install.pth file

    Using /tensorflow-2.0.0-rc2/python3.6
    Searching for torch==1.2.0
    Best match: torch 1.2.0
    Adding torch 1.2.0 to easy-install.pth file
    Installing convert-caffe2-to-onnx script to /usr/local/bin
    Installing convert-onnx-to-caffe2 script to /usr/local/bin

    Using /usr/local/lib/python3.6/dist-packages
    Searching for six==1.12.0
    Best match: six 1.12.0
    Adding six 1.12.0 to easy-install.pth file

    Using /usr/local/lib/python3.6/dist-packages
    Finished processing dependencies for elmoformanylangs==0.0.2

1 个答案:

答案 0 :(得分:-1)

e = Embedder('./zhs.model/')中的路径是绝对路径,而不是相对路径。 例如'/content/drive/Colab Notebooks/../zhs.model/'