ModuleNotFoundError:没有名为“ extruct”的模块Python 3.7 Jupyter Notebook

问题描述

我用pip安装了“挤压包”:

 pip install extruct

Collecting extruct Downloading https://files.pythonhosted.org/packages/d4/ab/9b705a8b2cf0bca59ec1b0729c8b8f80ecc8c79aced20463c1e19fa2bc99/extruct-0.10.0-py2.py3-none-any.whl Requirement already satisfied: six in /usr/lib/python2.7/dist-packages (from extruct) Collecting jstyleson (from extruct) Downloading https://files.pythonhosted.org/packages/5f/c1/3791e39d65c39b4e081010f2cf6f9443b7b6b9f6de63a5e458172c5c9376/jstyleson-0.0.2.tar.gz Collecting rdflib<5.0.0 (from extruct) Downloading https://files.pythonhosted.org/packages/c5/77/1fa0f4cffd5faad496b1344ab665902bb2609f56e0fb19bcf80cff485da0/rdflib-4.2.2.tar.gz (905kB) 100% |████████████████████████████████| 911kB 438kB/s Collecting lxml (from extruct) Downloading https://files.pythonhosted.org/packages/d1/2d/642ef7013aa56af52e14b5b7d53c5d591e6d038c9688e06d0f2a20ed26b2/lxml-4.5.2-cp27-cp27mu-manylinux1_x86_64.whl (5.5MB) 100% |████████████████████████████████| 5.5MB 90kB/s Collecting html-text>=0.5.1 (from extruct) Downloading https://files.pythonhosted.org/packages/e7/03/648294dbaa62e55d8622d7b0435b970ca45738498536b92e2f417e3fd531/html_text-0.5.2-py2.py3-none-any.whl Collecting w3lib (from extruct) Downloading https://files.pythonhosted.org/packages/a3/59/b6b14521090e7f42669cafdb84b0ab89301a42f1f1a82fcf5856661ea3a7/w3lib-1.22.0-py2.py3-none-any.whl Collecting mf2py (from extruct) Downloading https://files.pythonhosted.org/packages/fe/09/116b5b42f5c8cbb1cc43408be9df12fc2bf9fc408dfc9b20311ef4ffbfec/mf2py-1.1.2.tar.gz Collecting rdflib-jsonld (from extruct) Downloading https://files.pythonhosted.org/packages/f5/17/45e137be0d93b70827fe5529c0400731344a978bc792193d7d9152e6dbe4/rdflib-jsonld-0.5.0.tar.gz (55kB) 100% |████████████████████████████████| 61kB 1.9MB/s Collecting isodate (from rdflib<5.0.0->extruct) Downloading https://files.pythonhosted.org/packages/9b/9f/b36f7774ff5ea8e428fdcfc4bb332c39ee5b9362ddd3d40d9516a55221b2/isodate-0.6.0-py2.py3-none-any.whl (45kB) 100% |████████████████████████████████| 51kB 1.5MB/s Collecting pyparsing (from rdflib<5.0.0->extruct) Downloading https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67kB) 100% |████████████████████████████████| 71kB 2.1MB/s Collecting BeautifulSoup4>=4.6.0 (from mf2py->extruct) Downloading https://files.pythonhosted.org/packages/c2/39/1efce3dc73e657c43f436533d49be1491bf8fc830caa70188d73bfd03b8d/beautifulsoup4-4.9.1-py2-none-any.whl (111kB) 100% |████████████████████████████████| 112kB 2.1MB/s Collecting html5lib>=1.0.1 (from mf2py->extruct) Downloading https://files.pythonhosted.org/packages/6c/dd/a834df6482147d48e225a49515aabc28974ad5a4ca3215c18a882565b028/html5lib-1.1-py2.py3-none-any.whl (112kB) 100% |████████████████████████████████| 112kB 1.6MB/s Collecting requests>=2.18.4 (from mf2py->extruct) Downloading https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61kB) 100% |████████████████████████████████| 71kB 1.5MB/s Collecting soupsieve<2.0 (from BeautifulSoup4>=4.6.0->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/39/36/f35056eb9978a622bbcedc554993d10777e3c6ff1ca24cde53f4be9c5fc4/soupsieve-1.9.6-py2.py3-none-any.whl Collecting webencodings (from html5lib>=1.0.1->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests>=2.18.4->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl (127kB) 100% |████████████████████████████████| 133kB 1.4MB/s Collecting chardet<4,>=3.0.2 (from requests>=2.18.4->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB) 100% |████████████████████████████████| 143kB 2.1MB/s Collecting certifi>=2017.4.17 (from requests>=2.18.4->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl (156kB) 100% |████████████████████████████████| 163kB 1.4MB/s Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python2.7/dist-packages (from requests>=2.18.4->mf2py->extruct) Collecting backports.functools-lru-cache; python_version < "3" (from soupsieve<2.0->BeautifulSoup4>=4.6.0->mf2py->extruct) Downloading https://files.pythonhosted.org/packages/da/d1/080d2bb13773803648281a49e3918f65b31b7beebf009887a529357fd44a/backports.functools_lru_cache-1.6.1-py2.py3-none-any.whl Building wheels for collected packages: jstyleson,rdflib,mf2py,rdflib-jsonld Running setup.py bdist_wheel for jstyleson ... done Stored in directory: /root/.cache/pip/wheels/23/ac/3c/5c3d2849c2c9937c1d602b7ba099817c11bc5215abcd07ba4d Running setup.py bdist_wheel for rdflib ... done Stored in directory: /root/.cache/pip/wheels/8d/f6/b7/f5e9501d0f006fc9fd497c930206952856b2191ab5c836cb97 Running setup.py bdist_wheel for mf2py ... done Stored in directory: /root/.cache/pip/wheels/7e/50/a1/7cd28816aacb3aac8185cd1184f5518fa5daae0484dc3674b4 Running setup.py bdist_wheel for rdflib-jsonld ... done Stored in directory: /root/.cache/pip/wheels/8d/e4/7f/9ebcb3e400c694e645c3adba40ef3e9bda78384ac3b9b0d13d Successfully built jstyleson rdflib mf2py rdflib-jsonld Installing collected packages: jstyleson,isodate,pyparsing,lxml,html-text,w3lib,backports.functools-lru-cache,soupsieve,BeautifulSoup4,webencodings,html5lib,urllib3,chardet,certifi,requests,rdflib-jsonld,extruct Successfully installed BeautifulSoup4-4.9.1 backports.functools-lru-cache-1.6.1 certifi-2020.6.20 chardet-3.0.4 extruct-0.10.0 html-text-0.5.2 html5lib-1.1 isodate-0.6.0 jstyleson-0.0.2 lxml-4.5.2 mf2py-1.1.2 pyparsing-2.4.7 rdflib-4.2.2 rdflib-jsonld-0.5.0 requests-2.24.0 soupsieve-1.9.6 urllib3-1.25.10 w3lib-1.22.0 webencodings-0.5.1

一切都很好

但是Jupyter Notebook(python)发出错误消息。

import extruct as ext

 ---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-6eff935840a6> in <module>
----> 1 import extruct as ext

ModuleNotFoundError: No module named 'extruct' ```

解决方法

在终端

python3.7 -m pip install pip

在python中

python3.7 -m pip install extruct
,

要确保为“正确的” Python安装它,可以尝试使用IPython magic命令在Jupyter内部 pip安装它

%pip install extruct

在Jupyter笔记本或控制台窗口中。

使用pip install的问题是通常您会同时在计算机上安装多个不同版本的Python。您必须准确确定Jupyter安装中使用的是哪一个,并使用相应的pip。

出于个人原因,出于这个原因,我尝试坚持使用Anaconda安装。我总是使用~/anaconda3/bin/pip install [...]来安装软件包,并运行~/anaconda3/bin/jupyter-lab(或Spyder或IPython,具体取决于当前需要什么)。这样,我确定所有库都安装在该特定的Python安装上。