【问题标题】:cannot import sympy , scipy in IPython无法在 IPython 中导入 sympy 、 scipy
【发布时间】:2013-11-04 15:49:30
【问题描述】:

我无法使用 Ipython 从 Mac 终端导入 scipy、sympy。 我的 python 发行版是 Canopy,这也是我的默认 python 环境 (IPython 别名为 /Library/Enthought/Canopy_64bit/User/bin/ipython。)

操作系统为 OS X 10.9。

两次尝试的错误是:

In [3]: import sympy
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-7fb0c7cf9177> in <module>()
----> 1 import sympy

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/__init__.py in <module>()
     68 # This module is slow to import:
     69 #from physics import units
---> 70 from plotting import plot, Plot, textplot, plot_backends, plot_implicit
     71 from printing import pretty, pretty_print, pprint, pprint_use_unicode, \
     72     pprint_try_use_unicode, print_gtk, print_tree, pager_print, TableForm

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/plotting/__init__.py in <module>()
----> 1 from plot import plot_backends
      2 from plot_implicit import plot_implicit
      3 from proxy_pyglet import Plot
      4 from textplot import textplot
      5 from pygletplot import PygletPlot

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/plotting/plot.py in <module>()
     29 from sympy.core.compatibility import set_union
     30 import warnings
---> 31 from experimental_lambdify import (vectorized_lambdify, lambdify)
     32
     33 #TODO probably all of the imports after this line can be put inside function to

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/plotting/experimental_lambdify.py in <module>()
     71
     72 from sympy.external import import_module
---> 73 np = import_module('numpy')
     74 import warnings
     75

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/external/importtools.py in import_module(module, min_module_version, min_python_version, warn_not_installed, warn_old_version, module_version_attr, module_version_attr_call_args, __import__kwargs, catch)
    121
    122     try:
--> 123         mod = __import__(module, **__import__kwargs)
    124     except ImportError:
    125         if warn_not_installed:

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.py in <module>()
    141         return loader(*packages, **options)
    142
--> 143     import add_newdocs
    144     __all__ = ['add_newdocs']
    145

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/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 ###############################################################################

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/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 *

/Users/nick/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
      9 import re
     10 import warnings
---> 11 import numpy.core.numeric as NX
     12
     13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack, dot

AttributeError: 'module' object has no attribute 'core'

【问题讨论】:

  • 重新安装模块。升级到小牛之后出现了很多问题。
  • 我应该使用 Canopy 包管理器还是通过终端和 mac 端口重新安装它?
  • 如果要修复 Canopy,请使用 Canopy 的包管理器或 enpkg 命令行。

标签: python macos enthought sympy canopy


【解决方案1】:

我建议你删除:

~/Library/Enthought/Canopy_64bit/User/

然后重新启动 Canopy。标准包将被重新安装。您将需要重新安装/更新您之前添加或更新的任何软件包。

不要将 mac 端口与 Canopy 一起使用。它们不兼容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-18
    • 2012-05-14
    • 1970-01-01
    • 2019-10-25
    • 2017-09-19
    • 1970-01-01
    • 2014-08-27
    相关资源
    最近更新 更多