jupyter / jupyter/notebook

Jupyter fails if started outside home directory

Open
#4,229 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I did a fresh install of Anaconda 3.7 and tried opening a Jupyter notebook by doing the following:

1. Uninstalled Anaconda 3.6.
2. Deleted all anaconda, jupyter and python keys in the registry.
3. Deleted all anaconda, jupyter and python files and folders on the file system.
4. Rebooted.
5. Installed Anaconda 3.7 64-bit (on Windows 10 Pro 64-bit). I ticked the "add to path" option in the installer.
6. Open PowerShell.
7. `cd` to a directory that is not under my home directory.
8. Start jupyter notebook using `jupyter notebook` command.
9. Try opening a notebook by selecting it in the browser.

I get the following error:

```
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Tom Oakley> cd \code
PS C:\code> jupyter notebook
[I 09:57:26.662 NotebookApp] JupyterLab extension loaded from C:\Anaconda3.7\lib\site-packages\jupyterlab
[I 09:57:26.662 NotebookApp] JupyterLab application directory is C:\Anaconda3.7\share\jupyter\lab
[I 09:57:26.678 NotebookApp] Serving notebooks from local directory: C:\code
[I 09:57:26.678 NotebookApp] The Jupyter Notebook is running at:
[I 09:57:26.678 NotebookApp] http://localhost:8888/?token=5727bc46546f81bc6d795a7516f2758bfb01bdc764a47430
[I 09:57:26.678 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:57:26.725 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=5727bc46546f81bc6d795a7516f2758bfb01bdc764a47430
[I 09:57:27.787 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[W 09:57:38.081 NotebookApp] Notebook sandbox/parallel.ipynb is not trusted
[I 09:57:38.628 NotebookApp] Kernel started: 5296c75b-0bbe-45d9-897a-0d74a6a01dba
C:\code\sandbox
['.git', '.ipynb_checkpoints', '.mypy_cache', 'animation_example.py', 'parallel.ipynb', '__pycache__']
Traceback (most recent call last):
File "C:\Anaconda3.7\lib\shutil.py", line 557, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'test.py' -> 'test_dir.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Anaconda3.7\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Anaconda3.7\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda3.7\lib\site-packages\ipykernel_launcher.py", line 15, in
from ipykernel import kernelapp as app
File "C:\Anaconda3.7\lib\site-packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "C:\Anaconda3.7\lib\site-packages\ipykernel\connect.py", line 13, in
from IPython.core.profiledir import ProfileDir
File "C:\Anaconda3.7\lib\site-packages\IPython\__init__.py", line 54, in
from .core.application import Application
File "C:\Anaconda3.7\lib\site-packages\IPython\core\application.py", line 16, in
from copy import deepcopy
File "C:\code\sandbox\copy.py", line 9, in
shutil.move('test.py', 'test_dir.py')
File "C:\Anaconda3.7\lib\shutil.py", line 571, in move
copy_function(src, real_dst)
File "C:\Anaconda3.7\lib\shutil.py", line 257, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Anaconda3.7\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'test.py'
[I 09:57:41.612 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
C:\code\sandbox
['.git', '.ipynb_checkpoints', '.mypy_cache', 'animation_example.py', 'parallel.ipynb', '__pycache__']
Traceback (most recent call last):
File "C:\Anaconda3.7\lib\shutil.py", line 557, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'test.py' -> 'test_dir.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Anaconda3.7\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Anaconda3.7\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda3.7\lib\site-packages\ipykernel_launcher.py", line 15, in
from ipykernel import kernelapp as app
File "C:\Anaconda3.7\lib\site-packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "C:\Anaconda3.7\lib\site-packages\ipykernel\connect.py", line 13, in
from IPython.core.profiledir import ProfileDir
File "C:\Anaconda3.7\lib\site-packages\IPython\__init__.py", line 54, in
from .core.application import Application
File "C:\Anaconda3.7\lib\site-packages\IPython\core\application.py", line 16, in
from copy import deepcopy
File "C:\code\sandbox\copy.py", line 9, in
shutil.move('test.py', 'test_dir.py')
File "C:\Anaconda3.7\lib\shutil.py", line 571, in move
copy_function(src, real_dst)
File "C:\Anaconda3.7\lib\shutil.py", line 257, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Anaconda3.7\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'test.py'
[I 09:57:44.673 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
C:\code\sandbox
['.git', '.ipynb_checkpoints', '.mypy_cache', 'animation_example.py', 'parallel.ipynb', '__pycache__']
Traceback (most recent call last):
File "C:\Anaconda3.7\lib\shutil.py", line 557, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'test.py' -> 'test_dir.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Anaconda3.7\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Anaconda3.7\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda3.7\lib\site-packages\ipykernel_launcher.py", line 15, in
from ipykernel import kernelapp as app
File "C:\Anaconda3.7\lib\site-packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "C:\Anaconda3.7\lib\site-packages\ipykernel\connect.py", line 13, in
from IPython.core.profiledir import ProfileDir
File "C:\Anaconda3.7\lib\site-packages\IPython\__init__.py", line 54, in
from .core.application import Application
File "C:\Anaconda3.7\lib\site-packages\IPython\core\application.py", line 16, in
from copy import deepcopy
File "C:\code\sandbox\copy.py", line 9, in
shutil.move('test.py', 'test_dir.py')
File "C:\Anaconda3.7\lib\shutil.py", line 571, in move
copy_function(src, real_dst)
File "C:\Anaconda3.7\lib\shutil.py", line 257, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Anaconda3.7\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'test.py'
```

Updating the packages with `conda update --all` makes no difference.

Using `jupyter lab` gives the same error.

## Versions

```
jupyter 1.0.0 py37_7
jupyter_client 5.2.3 py37_0
jupyter_console 6.0.0 py37_0
jupyter_core 4.4.0 py37_0
jupyterlab 0.35.3 py37_0
jupyterlab_launcher 0.13.1 py37_0
jupyterlab_server 0.2.0 py37_0
```

`pandas.show_versions()` gives:
```
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.4
pytest: 4.0.0
pip: 18.1
setuptools: 40.6.2
Cython: 0.29
numpy: 1.15.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.1.1
sphinx: 1.8.2
patsy: 0.5.0
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.9
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.2
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.14
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
```

Please let me know how to fix this!

Contributor guide

Open the contributing guide

Research direction

Start with the traceback showing ipykernel importing C:\code\sandbox\copy.py while launching the kernel, then inspect the notebook kernel startup path. Reproduce the report from a directory outside the home directory and compare it with a directory that has no conflicting module. Done means the intended behavior and any required regression coverage are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.