1

我运行 Windows 7,Enthought Python Distribution 7.3-2 Academic。
我打开一个命令提示符,切换到我的代码目录并输入

U:\rsch>ipython notebook

在新笔记本中,我输入%pylab并收到以下错误:

In [1]: %pylab

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
U:\rsch\<ipython-input-1-5c1faa999e5b> in <module>()
----> 1 get_ipython().magic(u'pylab')

D:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in magic(self, arg_s, next_input)
   1983                 self._magic_locals = sys._getframe(1).f_locals
   1984             with self.builtin_trap:
-> 1985                 result = fn(magic_args)
   1986             # Ensure we're not keeping object references around:

   1987             self._magic_locals = {}

D:\Python27\lib\site-packages\IPython\core\magic.pyc in magic_pylab(self, s)
   3471             import_all_status = True
   3472 
-> 3473         self.shell.enable_pylab(s, import_all=import_all_status)
   3474 
   3475     def magic_tb(self, s):

D:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in enable_pylab(self, gui, import_all)
   2592         ns = {}
   2593         try:
-> 2594             gui = pylab_activate(ns, gui, import_all, self)
   2595         except KeyError:
   2596             error("Backend %r not supported" % gui)

D:\Python27\lib\site-packages\IPython\core\pylabtools.pyc in pylab_activate(user_ns, gui, import_all, shell)
    327     itself, and will be needed next to configure IPython's gui integration.
    328     """
--> 329     gui, backend = find_gui_and_backend(gui)
    330     activate_matplotlib(backend)
    331     import_pylab(user_ns, import_all)

D:\Python27\lib\site-packages\IPython\core\pylabtools.pyc in find_gui_and_backend(gui)
    194     """
    195 
--> 196     import matplotlib
    197 
    198     if gui and gui != 'auto':

D:\Python27\lib\site-packages\matplotlib\__init__.py in <module>()
    131 import sys, os, tempfile
    132 
--> 133 from matplotlib.rcsetup import (defaultParams,
    134                                 validate_backend,
    135                                 validate_toolbar,

D:\Python27\lib\site-packages\matplotlib\rcsetup.py in <module>()
     17 import warnings
     18 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
---> 19 from matplotlib.colors import is_color_like
     20 
     21 #interactive_bk = ['gtk', 'gtkagg', 'gtkcairo', 'fltkagg', 'qtagg', 'qt4agg',


D:\Python27\lib\site-packages\matplotlib\colors.py in <module>()
     50 """
     51 import re
---> 52 import numpy as np
     53 from numpy import ma
     54 import matplotlib.cbook as cbook

D:\Python27\lib\site-packages\numpy\__init__.pyc in <module>()
    141         return loader(*packages, **options)
    142 
--> 143     import add_newdocs
    144     __all__ = ['add_newdocs']
    145 

D:\Python27\lib\site-packages\numpy\add_newdocs.py in <module>()
      7 #       core/fromnumeric.py, core/defmatrix.py up-to-date.

      8 
----> 9 from numpy.lib import add_newdoc
     10 
     11 ###############################################################################


D:\Python27\lib\site-packages\numpy\lib\__init__.py in <module>()
     11 
     12 import scimath as emath
---> 13 from polynomial import *
     14 #import convertcode

     15 from utils import *

D:\Python27\lib\site-packages\numpy\lib\polynomial.py in <module>()
     15 from numpy.lib.function_base import trim_zeros, sort_complex
     16 from numpy.lib.type_check import iscomplex, real, imag
---> 17 from numpy.linalg import eigvals, lstsq
     18 
     19 class RankWarning(UserWarning):

D:\Python27\lib\site-packages\numpy\linalg\__init__.py in <module>()
     46 from info import __doc__
     47 
---> 48 from linalg import *
     49 
     50 from numpy.testing import Tester

D:\Python27\lib\site-packages\numpy\linalg\linalg.py in <module>()
     21         isfinite, size, finfo, absolute, log, exp
     22 from numpy.lib import triu
---> 23 from numpy.linalg import lapack_lite
     24 from numpy.matrixlib.defmatrix import matrix_power
     25 from numpy.compat import asbytes

ImportError: DLL load failed: The specified path is invalid.

不知道该怎么办。谢谢。

4

4 回答 4

1

我遇到了同样的问题,这对我有用:

  1. 我确保在没有“pylab”的情况下调用 IPython
  2. 然后,我确保所有会话/实例(对不起,但我是新手 :) 都已关闭。您可以通过 ctrl-C 在所有终端中执行此操作,如果可能,在笔记本仪表板中按“关闭”。

可能有更优雅的方法可以做到这一点,但这对我有用。

开发人员请注意,当他们尝试运行的第一个笔记本出现错误时,许多新手可能会感到非常沮丧。

亚当

于 2013-03-05T08:48:24.913 回答
0

EPD 随 ipython 0.12 一起提供。从那时起,Ipython 发展了很多。您应该通过输入“enpkg ipython”更新到 ipython 0.13.1,如下所述:https: //support.enthought.com/entries/22415022-Using-enpkg-to-update-EPD-packages

于 2013-02-08T21:11:47.277 回答
0

您可能在系统路径中缺少 Scripts 目录。要检查,运行

echo %PATH%

从命令提示符中查找D:\Python27\Scripts. 如果它丢失,您可以从控制面板手动添加它,或使用诸如Rapid Environment Editor之类的实用程序。

于 2013-02-08T20:36:04.027 回答
0

不幸的是,这些错误消息并没有真正有用。从消息中您只知道在导入“lapack_lite”(Numpy 的一部分)期间无法导入“某些 dll”。

您可以使用Dependency Walker查看导致问题的特定 DLL,打开“D:\Python27\Lib\site-packages\numpy\linalg\lapack_lite.pyd”可能会显示更多信息。

于 2013-02-11T14:32:23.650 回答