jupyter notebook FileNotFoundError - 在错误的Anaconda目录中寻找

15 浏览
0 Comments

jupyter notebook FileNotFoundError - 在错误的Anaconda目录中寻找

我在打开一个Jupyter笔记本文件时遇到了问题。当寻找Python时,Jupyter笔记本给出了一个FileNotFoundError错误:\n

Traceback (most recent call last):
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/notebook/base/handlers.py", line 503, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
        value = future.result()
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
        raise_exc_info(self._exc_info)
      File "", line 3, in raise_exc_info
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
        yielded = self.gen.throw(*exc_info)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 75, in post
        type=mtype))
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
        value = future.result()
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
        raise_exc_info(self._exc_info)
      File "", line 3, in raise_exc_info
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
        yielded = self.gen.throw(*exc_info)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
        value = future.result()
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
        raise_exc_info(self._exc_info)
      File "", line 3, in raise_exc_info
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
        yielded = self.gen.throw(*exc_info)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
        self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
        value = future.result()
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
        raise_exc_info(self._exc_info)
      File "", line 3, in raise_exc_info
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
        yielded = self.gen.throw(*exc_info)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 87, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/jupyter_client/manager.py", line 257, in start_kernel
        **kw)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/jupyter_client/manager.py", line 203, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/jupyter_client/launcher.py", line 128, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/subprocess.py", line 707, in __init__
        restore_signals, start_new_session)
      File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/subprocess.py", line 1326, in _execute_child
        raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: '/Users/myusername/anaconda3/envs/py3/bin/python'

\n我正在参加一个在线课程。我开始创建一个conda环境,如下所示:\n

conda create --name dlnd python=3
source activate dlnd
conda install numpy matplotlib pandas jupyter notebook

\n然后我尝试打开课程中提供的文件:\n

jupyter notebook dlnd-your-first-neural-network.ipynb

\n这时候就出现了错误。\n我怀疑问题是我没有/Users/myusername/anaconda3/目录(因此出现了FileNotFoundError)。我所有的anaconda东西都安装在/Users/myusername/anaconda/,我已经使用jupyter笔记本几周了,在各种环境中运行各种.ipynb文件,没有出现什么大问题。\n我不确定为什么jupyter笔记本在这个特定的情况下在anaconda3/中查找。我已经尝试重新安装,但是一切都安装在/Users/myusername/anaconda/中。\n有经验的人知道我缺少什么吗?\n使用Macbook pro 10.11。

0
0 Comments

问题的原因是在Jupyter Notebook中没有找到指定的Anaconda目录。解决方法是修改kernal.json文件中的Anaconda目录路径,将"anaconda3"改为"anaconda"。然后重新运行Jupyter Notebook,但是会出现新的错误,提示找不到指定的Anaconda环境。通过查看.ipynb文件的元数据发现,指定了"python3"的内核,但没有指定"py3"的环境。最终解决方法是创建一个"py3"环境,并安装ipykernel等所需依赖。这样就能成功运行Jupyter Notebook了。

0