Reputation: 2991
I am having trouble opening a jupyter notebook file. Jupyter notebook is giving me a FileNotFoundError error when looking for Python:
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 "<string>", 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 "<string>", 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 "<string>", 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 "<string>", line 3, in raise_exc_info
File "/Users/myusername/anaconda/envs/dlnd/lib/python3.6/site-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
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'
I am following an online class. I started by creating a conda environment as shown below:
conda create --name dlnd python=3
source activate dlnd
conda install numpy matplotlib pandas jupyter notebook
Then I try to open the file given in the class:
jupyter notebook dlnd-your-first-neural-network.ipynb
And this is when the error occurs.
I suspect the issue is that I have no /Users/myusername/anaconda3/
directory (thus the FileNotFoundError
). All of my anaconda stuff installed in /Users/myusername/anaconda/
, and I have been using jupyter notebooks for a couple weeks now, running various .ipynb
files in various environments, with no major issues.
I'm not sure why jupyter notebook is looking in anaconda3/
in the particular instance. I have tried reinstalling, but again everything is installed at /Users/myusername/anaconda/
.
Anyone with more experience know what I'm missing?
Using a Macbook pro on 10.11
Upvotes: 3
Views: 14528
Reputation: 2991
Based on @NehalJWani suggested post, I found /Users/myusername/Library/Jupyter/kernels/python3/kernal.json
, shown here:
{
"argv": [
"/Users/myusername/anaconda3/envs/py3/bin/python",
"-m",
"ipykernel",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
And modified it to specify anaconda
instead of anaconda3
:
{
"argv": [
"/Users/myusername/anaconda/envs/py3/bin/python",
"-m",
"ipykernel",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
Trying to rerun the jupyter notebook, the new error was then:
FileNotFoundError: [Errno 2] No such file or directory:
'/Users/myusername/anaconda/envs/py3/bin/python'
Which is a step in the right direction, because at least now we are looking in anaconda
instead of anaconda3
. However, it is also looking in envs/py3/
, and I do not have a py3
environment.
Looking at the .ipynb
file like @darthbith suggested, the file metadata is:
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
I see that the python3
kernel is specified here, but not the py3
environment.
Ultimately I ended up just making a py3
environment in place of my desired dlnd
environment:
conda create -n py3 python=3
Trying to run the notebook again I get this error:
/Users/myusername/anaconda/envs/py3/bin/python:
No module named ipykernel
And so I just install ipykernal
along with the other dependencies I would have needed eventually anyways:
conda install ipykernel numpy matplotlib pandas jupyter notebook
And now it works.
Upvotes: 4