简体   繁体   中英

PyDev/Eclipse not loading _mklinit when run from a Conda environment

I created a conda environment - testenv2 - installed python/numpy/pandas. Added it as the interpreter in Eclipse project settings and using it to run my test python script. And I am getting the below error. The same test script works fine from command line when I activate the conda environment and run from with in it. It also works from PyCharm. But somehow fails to launch in Eclipse.

Traceback (most recent call last):
  File "C:\Data\projects\eclipse-workspace\PythonEclipse\Test.py", line 1, in <module>
    import numpy as np
  File "C:\Data\devtools\Anaconda3\envs\testenv2\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Data\devtools\Anaconda3\envs\testenv2\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

If I just run the same test script using my root Conda Python interpreter, it works fine. So it is only when I try to use the environment I created from conda.

Thanks for the help!

Add CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1 to your environment variables.

For VSCode, either an .env file in your workspace folder or "env" key in launch.json should do the trick.

Source: https://docs.conda.io/projects/conda/en/latest/user-guide/troubleshooting.html#numpy-mkl-library-load-failed

我必须将以下内容放入我的路径环境变量中: E:\\program\\Anaconda3\\Library\\bin ,否则我遇到了同样的问题。

1.First open Anaconda Powershell Prompt and run the command

conda activate (path where you have the anaconda environment)

2.then open System-->Advanced System Settings-->Environment variables

a.in the User variable Path change the path to

(path where you have the anaconda environment)Library\bin

b.in the System variable add a new variable PYTHONPATH and give its path as

(path where you have the anaconda environment)\Lib;(path where you have the anaconda environment)\DLLs;(path where you have the anaconda environment)\Lib\lib-tk;(Drive where you have the anaconda environment)\other-folders-on-the-path

3.close eclipse and run again

Here you can find the section of the troubleshooting page for conda related to your issue and I think the inactive environment is the problem here.

With the latest conda version the developers decided that instead of polluting your environment variables with their paths you need to ensure your environment is activated when performing any action in it, otherwise things like required DLLs will not be found.

Current IDEs have not necessarily adapted to that change yet, I myself can't use integrated Python consoles in PyCharm because it tries to run it without activating the environment beforehand. Apparently the issue should be fixed in the next release.

Anyways, if you can't make your IDE activate conda environments before running any commands, you'll just have to bear with using ordinary terminals, where you can ensure the environment is active.

Add DLL location (C:\\Programs\\Python\\Python35\\DLLs) in the Environment variables path. This worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM