本文介绍了从lxml导入etree ImportError:DLL加载失败:找不到指定的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了新的Anaconda版本2019-10,该版本使用python 3.7.4.为了能够在Python中读取/写入MsWord .docx文件,我使用了库模块python-docx,我安装的是: conda install -c conda-forge python-docx 安装的是python-docx 0.8.10.现在是我以前使用anaconda安装(我不知道python3.5.4和python-docx版本)时经常用来读写MsWord .docx文件的python脚本.

I recently installed a fresh Anaconda version 2019-10, which uses python 3.7.4.To be able to read/write MsWord .docx files from within Python I use library module python-docx,which I installed with:conda install -c conda-forge python-docxInstalled is python-docx 0.8.10.Now a python script that I frequently used to read/write MsWord .docx files with my previous anaconda installation (with python3.5.4 and python-docx version unknown to me).

脚本:(缩短)


    import docx
    doc = docx.Document('demo.docx') # demo.docx exists in same dir
    print(len(doc.paragraphs))

突然抛出一个错误:

回溯(最近通话最近一次):

Traceback (most recent call last):

  File "D:\pa\Python\ProjectsWorkspace\Py001Proj\src\printenfrompython\wordprinten.py", line 19, in <module>
    import docx
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\__init__.py", line 3, in <module>
    from docx.api import Document  # noqa
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\api.py", line 14, in <module>
    from docx.package import Package
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\package.py", line 9, in <module>
    from docx.opc.package import OpcPackage
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\package.py", line 9, in <module>
    from docx.opc.part import PartFactory
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\part.py", line 12, in <module>
    from .oxml import serialize_part_xml
  File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\oxml.py", line 12, in <module>
    from lxml import etree
ImportError: DLL load failed: The specified module could not be found.

是否有解决此问题的方法?我无法返回到以前的安装!

Is there a solution to this problem?I cannot go back to my previous installation!

今天,我使用以下命令在普通的python3.7.5安装中安装了python-docx:'pip install python-docx'现在,不会发生上述错误.重新安装Anaconda并使用pip在anaconda中重新安装python-docx,并发生与上述相同的错误.我的操作系统是Windows10.我在两种情况下都使用Eclipse \ PyDev运行测试,然后在python3.7.5和anaconda python3.7.4解释器之间切换PyDev.

Today I installed python-docx in my plain python3.7.5 installation using: 'pip install python-docx` Now the above error does not occur.Re-installed Anaconda and re-installed python-docx in anaconda with pip and the same error as above occurs. My OS is windows10. I run the test in both cases with Eclipse\PyDev, and switch in PyDev between the python3.7.5 and anaconda python3.7.4 interpreter.

推荐答案

conda版本:4.9.2(安装在系统中)尝试运行:

conda version : 4.9.2 (Installed in system)Trying to run:

scrapy startproject name_of_project

错误:

ImportError: DLL load failed while importing etree: The specified module could not be found.

解决方案:

第一步:pip卸载lxml

Step 1: pip uninstall lxml

第2步:pip安装lxml

Step 2: pip install lxml

错误已解决

New Scrapy project 'tutorial', using template directory 'C:\Users\New\miniconda3\lib\site-packages\scrapy\templates\project', created in:
    C:\Users\New\Documents\TOUR_TOC++\web_scraping\NSE\tutorial
    You can start your first spider with:
         cd tutorial
         scrapy genspider example example.com ...

这篇关于从lxml导入etree ImportError:DLL加载失败:找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 07:22