FileNotFoundError:[Errno 2]没有这样的文件或目录:' /Library/Frameworks/Python.framework/Versions/3.4/bin/python3'

时间:2017-06-14 07:13:55

标签: macos python-3.x anaconda jupyter-notebook jupyter

当我想在Jupyter笔记本中执行我的代码时,我收到此错误:

Traceback (most recent call last):
  File "//anaconda/lib/python3.6/site-packages/notebook/base/handlers.py", line 503, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "//anaconda/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "//anaconda/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 75, in post
    type=mtype))
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "//anaconda/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "//anaconda/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 "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "//anaconda/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "//anaconda/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 "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "//anaconda/lib/python3.6/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "//anaconda/lib/python3.6/site-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "//anaconda/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 87, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "//anaconda/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "//anaconda/lib/python3.6/site-packages/jupyter_client/manager.py", line 243, in start_kernel
    **kw)
  File "//anaconda/lib/python3.6/site-packages/jupyter_client/manager.py", line 189, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "//anaconda/lib/python3.6/site-packages/jupyter_client/launcher.py", line 123, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "//anaconda/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "//anaconda/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: '/Library/Frameworks/Python.framework/Versions/3.4/bin/python3'

以下是更多信息:

Monas-MacBook-Pro:~ mona$ python
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import matplotlib
>>> import pandas
>>> import IPython
>>> import seaborn
>>> print(seaborn.__version__)
0.7.1
>>> quit()
Monas-MacBook-Pro:~ mona$ uname -a
Darwin Monas-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Tue Apr 11 16:00:51 PDT 2017; root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64
Monas-MacBook-Pro:~ mona$ jupyter --version
4.2.1

Monas-MacBook-Pro:~ mona$ ipython3
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: print("mona")
mona

基本上,想知道为什么Jupyter正在寻找Library/Frameworks/Python.framework/Versions/3.4/bin/python3(它不存在)而不是Anaconda版本?还有,如何设置它以使用Anaconda Python?

1 个答案:

答案 0 :(得分:0)

使用Anaconda重新安装Python3,现在内核工作正常:

Monas-MacBook-Pro:~ mona$ pip -V
pip 9.0.1 from /Users/mona/anaconda/lib/python3.6/site-packages (python 3.6)
Monas-MacBook-Pro:~ mona$ python -c 'import pkg_resources'
Monas-MacBook-Pro:~ mona$ python -c 'import setuptools'
Monas-MacBook-Pro:~ mona$ jupyter notebook
[I 01:23:18.296 NotebookApp] Serving notebooks from local directory: /Users/mona
[I 01:23:18.296 NotebookApp] 0 active kernels 
[I 01:23:18.296 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=133646a3bb56bf23640249efb3959b2babd83df094abe903
[I 01:23:18.297 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 01:23:18.312 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=133646a3bb56bf23640249efb3959b2babd83df094abe903
[I 01:23:19.531 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 01:23:25.937 NotebookApp] Creating new notebook in 
[I 01:23:27.497 NotebookApp] Kernel started: 3b3719c3-ac16-4d52-890b-53a0638eaca8