导入错误:在Jupyter笔记本中无法加载DLL,但在.py文件中正常工作。

10 浏览
0 Comments

导入错误:在Jupyter笔记本中无法加载DLL,但在.py文件中正常工作。

我在Anaconda环境中安装了BreakoutDetection模块。当我尝试在jupyter notebook中使用import breakout_detection导入该模块时,出现以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 in ()
----> 1 import breakout_detection
C:\Users\sgadiyar\AppData\Local\Continuum\Anaconda2\lib\site-packages\breakout_detection.py in ()
     15         except ImportError:
     16             return importlib.import_module('_breakout_detection')
---> 17     _breakout_detection = swig_import_helper()
     18     del swig_import_helper
     19 elif _swig_python_version_info >= (2, 6, 0):
C:\Users\sgadiyar\AppData\Local\Continuum\Anaconda2\lib\site-packages\breakout_detection.py in swig_import_helper()
     14             return importlib.import_module(mname)
     15         except ImportError:
---> 16             return importlib.import_module('_breakout_detection')
     17     _breakout_detection = swig_import_helper()
     18     del swig_import_helper
C:\Users\sgadiyar\AppData\Local\Continuum\Anaconda2\lib\importlib\__init__.pyc in import_module(name, package)
     35             level += 1
     36         name = _resolve_name(name[level:], package, level)
---> 37     __import__(name)
     38     return sys.modules[name]
ImportError: DLL load failed: The specified procedure could not be found.

我可以在python shell中导入相同的模块。

我查看了系统路径(print sys.path)以及python shell和jupyter notebook中的路径。它们都是相同的。可执行路径(print sys.executable)也是相同的。

有人可以帮我解决这个问题吗?谢谢!

0
0 Comments

问题原因:Anaconda重新安装到新目录后,系统变量PATH未正确更新,导致在Jupyter Notebook中无法加载DLL文件。

解决方法:根据"Import error: DLL load failed in Jupyter notebook but working in .py file"问题中的回答,通过以下步骤解决问题:

1. 打开CMD窗口,并执行以下命令:

- activate base

- jupyter notebook

或者执行以下命令:

- activate root

- jupyter notebook

这样可以临时解决问题,但无法在当前打开的PowerShell窗口所在的文件夹中启动Jupyter Notebook。

2. 打开系统变量PATH,将旧的D:驱动器更改为当前的C:驱动器,并添加以下路径:

- c:\users\USERNAME\anaconda3

- c:\users\USERNAME\anaconda3\scripts

- c:\users\USERNAME\anaconda3\library\bin

- c:\users\USERNAME\anaconda3\library\usr\bin

其中,c:\users\USERNAME\anaconda3为Anaconda的安装路径。

以上是解决"Import error: DLL load failed in Jupyter notebook but working in .py file"问题的原因和解决方法。

0
0 Comments

问题的原因是在Jupyter notebook中出现了"Import error: DLL load failed"错误,但是在.py文件中可以正常工作。问题的解决方法是通过在命令行中激活根环境"activate base",然后运行"jupyter notebook"命令。在激活根环境后,命令行提示符会发生变化。需要注意的是,"activate base"命令在PowerShell中不起作用,必须切换到命令提示符(cmd)中运行,或者可以尝试在命令提示符中运行整个过程。如果所需的路径在PowerShell环境中可用,那么就不需要激活"base"环境。这种方法适用于Windows Server(2016 Datacenter)。需要注意的是,Anaconda的目的是拥有不同的工作环境,因此仅在base环境中运行Jupyter不是解决方案。只需要将路径添加到PATH变量中即可解决问题。感谢回答中提到的"activate base"命令。

0
0 Comments

在Jupyter notebook中出现“Import error: DLL load failed”错误的原因是环境未激活导致的。解决方法是在命令提示符中先激活环境,然后再运行Jupyter notebook。

在Windows系统中,可以通过以下步骤解决该问题:

1. 打开命令提示符。

2. 输入activate root来激活环境。

3. 输入jupyter notebook来运行Jupyter notebook。

通过这样的方式,可以成功解决“Import error: DLL load failed”错误。然而,这也引发了一个问题,为什么需要激活环境?之前并不需要这样做。

我认为这是一个新的强制性功能,用于更好地控制环境。这就是所有的内容了。

0