Ipython笔记本。 Windows 7中%pylab加载错误

时间:2013-02-08 20:13:13

标签: python windows-7 ipython enthought ipython-notebook

我运行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 个答案:

答案 0 :(得分:1)

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

  1. 我确保将IPython称为,不带“pylab”
  2. 然后我确定所有的会话/实例(对不起,但我是新来的:)已关闭。您可以通过ctrl-C在所有终端中执行此操作,并在Notebook仪表板中按“关闭”(如果可能)。
  3. 这可能有更优雅的方法,但这对我有用。

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

    亚当

答案 1 :(得分:0)

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

echo %PATH%

从命令提示符处查找D:\Python27\Scripts。如果缺少,可以从控制面板手动添加,或使用Rapid Environment Editor等实用程序。

答案 2 :(得分:0)

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

答案 3 :(得分:0)

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

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