lxml installed with conda: “ImportError: DLL load failed: The specified procedure could not be found”

给你一囗甜甜゛ 提交于 2021-01-28 18:56:00

问题


I am using anaconda on windows 10 with the lastest version of conda 4.5.12. I am creating a very simple test env to try to install lxml with python 3.6.6.

Here my environment.yml file:

channels:
- defaults
dependencies:
- python=3.6.6
- lxml

Then I create an env using conda:

conda env create -f environment_test.yml -n test26

Here the list of packages after the installation:

(test26) C:>conda list
# packages in environment at C:\Program Files\Anaconda3\envs\test26:
#
# Name                    Version                   Build  Channel
certifi                   2018.11.29               py36_0    defaults
libiconv                  1.15                 h1df5818_7    defaults
libxml2                   2.9.8                hadb2253_1    defaults
libxslt                   1.1.32               hf6f1972_0    defaults
lxml                      4.2.5            py36hef2cd61_0    defaults
pip                       18.1                     py36_0    defaults
python                    3.6.6                hea74fb7_0    defaults
setuptools                40.6.3                   py36_0    defaults
vc                        14.1                 h0510ff6_4    defaults
vs2015_runtime            14.15.26706          h3a45250_0    defaults
wheel                     0.32.3                   py36_0    defaults
wincertstore              0.2              py36h7fe50ca_0    defaults
zlib                      1.2.11               h62dcd97_3    defaults

So far so good. The issue is when I tried to import the package lxml

(test26) C:>python
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.

With verbose info (another test with env: "test29"):

>>> from lxml import etree
# C:\Program Files\Anaconda3\envs\test29\lib\site-packages\lxml\__pycache__\__init__.cpython-36.pyc matches C:\Program Files\Anaconda3\envs\test29\lib\site-packages\lxml\__init__.py
# code object from 'C:\\Program Files\\Anaconda3\\envs\\test29\\lib\\site-packages\\lxml\\__pycache__\\__init__.cpython-36.pyc'
import 'lxml' # <_frozen_importlib_external.SourceFileLoader object at 0x00000160F1B643C8>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1023, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified procedure could not be found.

How can I debug this issue ? Do I missed dependency ?

On MacOS, I don't see the issue so it seems specific to Windows. Is there an older version working on Windows (I tried 4.1.1 and 4.2.1)

The env is created/activated using the Anaconda prompt with Windows 10 and the env is activated with:

conda activate env test29

回答1:


One of the thing we discover is that some applications are creating some lib under C:\Windows\System32\ and this is a very bad practice. At the end I did the following:

  1. remove C:\Windows\System32\libxml2.dll
  2. remove C:\Windows\System32\iconv.dll

Everything is working well with this env and so far I got now issue with my Windows applicarions. Thanks to Ray from the Anaconda team for the help.



来源:https://stackoverflow.com/questions/54075542/lxml-installed-with-conda-importerror-dll-load-failed-the-specified-procedur

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!