0

I faced with problem when I installed python-pptx with conda on cleaned environment: conda install -c conda-forge python-pptx. After install was successfully finished I tried to import pptx module and got following error:

>>> import pptx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\SazonovEO\AppData\Local\Continuum\anaconda3\envs\new\lib\site-p
ackages\pptx\__init__.py", line 13, in <module>
    from pptx.api import Presentation  # noqa
  File "C:\Users\SazonovEO\AppData\Local\Continuum\anaconda3\envs\new\lib\site-p
ackages\pptx\api.py", line 17, in <module>
    from .package import Package
  File "C:\Users\SazonovEO\AppData\Local\Continuum\anaconda3\envs\new\lib\site-p
ackages\pptx\package.py", line 13, in <module>
    from .opc.package import OpcPackage
  File "C:\Users\SazonovEO\AppData\Local\Continuum\anaconda3\envs\new\lib\site-p
ackages\pptx\opc\package.py", line 13, in <module>
    from .oxml import CT_Relationships, serialize_part_xml
  File "C:\Users\SazonovEO\AppData\Local\Continuum\anaconda3\envs\new\lib\site-p
ackages\pptx\opc\oxml.py", line 12, in <module>
    from lxml import etree
ImportError: DLL load failed: Не найден указанный модуль.

But if I installed this library (python-pptx) with pip like this (also into new cleaned environment):

pip install python-pptx

this works. I have following versions: python version - 3.7.1, python-pptx-0.6.17, lxml-4.3.0.

Do you have any ideas about this issue?

EugenS
  • 83
  • 11
  • Strange, you say you have `lxml`, and it's in the `python-pptx` recipe as a requirement, but Python says it can't find it. Can you `import lxml` in that env or does that also fail? If you check `sys.path` in Python, is `lxml` in one of those directories? – merv Mar 17 '19 at 21:12
  • 1
    `lxml` is a Python wrapper for `lib2xml` and `libxslt`. These are DLLs in Windows I believe, which might mean they can't be found by `lxml` in the anaconda environment for some reason (perhaps PATH-related). The fact the error messages says "DLL load failed" rather than "No module named lxml" would indicate that finding the `lxml` module isn't the immediate problem. Might be worth trying `conda install lxml` or whatever the command is for reinstalling lxml in anaconda, to see if that picks up the underlying C-libraries. Also this might help: https://github.com/sci-bots/microdrop/issues/246 – scanny Mar 17 '19 at 21:39

2 Answers2

0

Reinstallation lxml from pkgs/main channel from anaconda repo allow workaround issue:

conda install lxml

The following packages will be UPDATED:

libxml2 conda-forge::libxml2-2.9.8-h9ce36c8_1~ --> pkgs/main::libxm l2-2.9.9-h464c3ec_0 libxslt
conda-forge::libxslt-1.1.32-heafd4d3_~ --> pkgs/main::libxs lt-1.1.33-h579f668_0

The following packages will be SUPERSEDED by a higher-priority channel: ... lxml
conda-forge::lxml-4.3.2-py37heafd4d3_0 --> pkgs/main::lxml- 4.3.2-py37h1350720_0 ...

EugenS
  • 83
  • 11
0

First of all, try the following command in your terminal in order to enable the conda-forge:

conda config --add channels conda-forge

Secondly, run the following command and after a while enter [y]:

conda install python-pptx