How to reset iPython/Jupyter profile after upgrade to 'factory' defaults?
Fixed!
I'm guessing there is a directed-ness to the Jupyter system (python, ipython, jupyter, a browser) where I have to reset parts in order.
I will take a guess and put these in a specific order. (Others can reorder if this turns out meaningful):
- Update python packages
- Created a new iPython profile:
$ ipython profile create foo
- Rename
profile_foo
toprofile_default
- Initialize a Jupyter profile:
$ jupyter notebook --generate-config
- Clear the cache in your browser **:
- Chrome (v52),
- "Cookies and other site data"
- "Cached images and files"
- Firefox (v47),
- "Offline web content and user data"
- "Cached web content"
- Chrome (v52),
CAUTION: I'm assuming any existing iPython/Jupyter settings are not an issue, because the goal is to restore to factory, so to speak. And, I'm also assuming you're trying not to delete your saved passwords or bookmarks or history during a browser cache clearing step.
** I'm not clear which cache settings specifically include iPython/Jupyter data. These are only the settings I used and the problem was fixed.
Change IPython/Jupyter notebook working directory
jupyter notebook --help-all
could be of help:
--notebook-dir=<Unicode> (NotebookManager.notebook_dir)
Default: u'/Users/me/ipynbs'
The directory to use for notebooks.
For example:
jupyter notebook --notebook-dir=/Users/yourname/folder1/folder2/
You can of course set it in your profiles if needed, you might need to escape backslash in Windows.
Note that this will override whatever path you might have set in a jupyter_notebook_config.py file. (Where you can set a variable c.NotebookApp.notebook_dir
that will be your default startup location.)
How to change the Jupyter start-up folder
Jupyter Notebook and JupyterLab < 3.0
For old Jupyter Notebook interface installed with notebook
package and run as jupyter notebook
(see the next section for the identical interface installed with nbclassic
and run with jupyter nbclassic
, and for JupyterLab):
Open
cmd
(or Anaconda Prompt) and runjupyter notebook --generate-config
.This writes a file to
C:\Users\username\.jupyter\jupyter_notebook_config.py
.Browse to the file location and open it in an Editor
Search for the following line in the file:
#c.NotebookApp.notebook_dir = ''
Replace by
c.NotebookApp.notebook_dir = '/the/path/to/home/folder/'
Make sure you use forward slashes in your path and use /home/user/ instead of ~/ for your home directory, backslashes could be used if placed in double quotes even if folder name contains spaces as such :
"D:\yourUserName\Any Folder\More Folders\"
Remove the
#
at the beginning of the line to allow the line to execute
JupyterLab >= 3, Jupyter Notebook Classic, and RetroLab
For recent nbclassic
and JupyterLab >= 3 use c.ServerApp.root_dir
instead of c.NotebookApp.notebook_dir
(and jupyter server --generate-config
instead of jupyter notebook --generate-config
).
For context see migration guide and this question on differences between server
and notebook
.
How to change the default browser used by the ipython/jupyter notebook in Linux?
You can create jupyter_notebook_config.py
by:
jupyter notebook --generate-config
Then you go to
~/.jupyter/jupyter_notebook_config.py
and change
# c.NotebookApp.browser = ''
to for example:
c.NotebookApp.browser = '/usr/bin/google-chrome %s'
You can choose which ever browser is installed. You'll find the path for example by typing which firefox
Do not forget to delete the #
Changing the default port for iPython notebook server / Jupyter
jupyter notebook --ip=0.0.0.0 --port=80 or
ipython notebook --ip=0.0.0.0 --port=80
is what i did to run ipython in my vagrant box. (Opened up the ports on the vagrant box to access it on my host mac)
usage: ipython [-h] [--certfile NOTEBOOKAPP.CERTFILE] [--ip NOTEBOOKAPP.IP]
[--pylab [NOTEBOOKAPP.PYLAB]]
[--log-level NOTEBOOKAPP.LOG_LEVEL]
[--port-retries NOTEBOOKAPP.PORT_RETRIES]
[--notebook-dir NOTEBOOKAPP.NOTEBOOK_DIR]
[--config NOTEBOOKAPP.CONFIG_FILE]
[--keyfile NOTEBOOKAPP.KEYFILE] [--port NOTEBOOKAPP.PORT]
[--transport KERNELMANAGER.TRANSPORT]
[--browser NOTEBOOKAPP.BROWSER] [--script] [-y] [--no-browser]
[--debug] [--no-mathjax] [--no-script] [--generate-config]
Incase the port is already occupied, see what's blocking it - inmy case it was an old instance of ipython which had not been terminated properly. I kiiled them all with this command
ps auxww | grep 'ipython' | awk '{print $2}' | xargs sudo kill -9
Mysteriously assigned constructor argument in iPython
Here is a correct dummy.py
script without a mutable as default value for the argument:
class Dummy():
def __init__(self, others=None):
self._others = others or []
pass
def receive(self, value):
self._others.append(value)
@property
def others(self):
return self._others
Output:
created = []
received = ['something']
Related Topics
How to Get Window Id for Xdotool Automatically
Running Shell Script After Boot on Raspberry Pi
Sending Mail in Bash Script Outputs Literal \N Instead of a New Line
Add a Directory When Creating Tar Archive
Tensorflow Recommended System Specifications
"Sort Filename | Uniq" Does Not Work on Large Files
Shell Programming: Executing Two Applications at The Same Time
Wmctrl: Moving a Fullscreen Window
Open Website from Within Eclipse's Internal Browser
Jmp Unexpected Behavior in Shellcode When Next(Skipped) Instruction Is a Variable Definition
Why Sigint Can Stop Bash in Terminal But Not via Kill -Int
Setting Path to Shared Library Inside a Makefile for Compile
How to Send Integer with Message Queue with Posix API in Linux
Find Is Returning "Find: .: Permission Denied", But I Am Not Searching In