gpt4 book ai didi

python - 两种形式的 Jupyter notebook 的问题

转载 作者:行者123 更新时间:2023-11-28 18:32:56 28 4
gpt4 key购买 nike

最近,我在我的 Jupyter 笔记本上安装了第二个版本的 Python,这样我就可以在需要时使用 Python 2 或 3。但是,在安装 Python 3 之后,我在以前的 python2 笔记本上遇到了 matplotlib、scipy 和 numpy 的问题。

输入:

%pylab inline
import time
import datetime
import glob
import os
from os import system
import platform
import scipy.ndimage as snd
import numpy as np
from matplotlib.pyplot import *

给我:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-fe04d06772cd> in <module>()
----> 1 get_ipython().magic(u'pylab inline')
2 import time
3 import datetime
4 import glob
5 import os

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2334 magic_name, _, magic_arg_s = arg_s.partition(' ')
2335 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2336 return self.run_line_magic(magic_name, magic_arg_s)
2337
2338 #-------------------------------------------------------------------------

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2255 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2256 with self.builtin_trap:
-> 2257 result = fn(*args,**kwargs)
2258 return result
2259

<decorator-gen-107> in pylab(self, line)

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in pylab(self, line)
154 import_all = not args.no_import_all
155
--> 156 gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)
157 self._show_matplotlib_backend(args.gui, backend)
158 print ("Populating the interactive namespace from numpy and matplotlib")

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all, welcome_message)
3169 from IPython.core.pylabtools import import_pylab
3170
-> 3171 gui, backend = self.enable_matplotlib(gui)
3172
3173 # We want to prevent the loading of pylab to pollute the user's

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
3118 """
3119 from IPython.core import pylabtools as pt
-> 3120 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
3121
3122 if gui != 'inline':

/Users/stephanng/anaconda/envs/py27/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in find_gui_and_backend(gui, gui_select)
237 """
238
--> 239 import matplotlib
240
241 if gui and gui != 'auto':

ImportError: No module named matplotlib

我从中得到的是 Python 2 在查看导入时不再指向正确的目录。我该如何设置正确目录的路径?

最佳答案

我完全卸载了所有内容,然后重新安装,路径已更正。

关于python - 两种形式的 Jupyter notebook 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35212505/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com