The %store magic feature can save large python objects for you to use in between different sessions, but I'd like to find out where the files are actually located so I can also transfer them between different computers. I am using Windows 7.
IPython does that, see github for storemagic.py
Stored value will be kept under %IPYTHONDIR/<profile_name>/db/autorestore/<variable_name>
Or by default ~/.ipython/profile_default/db/autorestore/<variable_name>
Related
I am using 2 computers to code in VS Code, but I want to sync a specific file when I edit it in both computers. Do you have any extensions, or servers that allows it to sync?
I tried looking in Google, some said try FTP, and some said use "Settings Sync". (I installed Settings Sync, but I don't really know if it can sync my files.)
Option 1
Use vscode remote development.
Select main machine which would host all the files and use SSH to access the files from the other machine.
Option 2
Rsync is a standard linux tool which can be used.
Use can use vscode rsync extension for syncing the files from one machine into the other.
I think that the closest experience to what you have in mind that you can get currently on VSCode is Visual Studio Live Share. This is an official extensions suite that lets you share your screen with multiple hosts, it also shares most of your current VSCode editor features (like intellisense) and can be enabled with voice and text chats. I would also suggest to set up a git repository for the files you are going to work with, so that hard copies of all your files will be avaialble to all your users.
I have two different Jupyter notebooks for two different projects. I would like to merge them to get them both on the same notebook.
One way is to copy cells from one to the other one but it seems to be quite a bit of work for projects containing many cells. Is there a feature supporting importing Notebook documents or copying multiple cells at a time?
You can merge notebooks with nbmerge
Install it with pip
pip install nbmerge
and merge your files with
nbmerge file_1.ipynb file_2.ipynb file_3.ipynb > merged.ipynb
pip install nbmerge
nbmerge file_1.ipynb file_2.ipynb file_3.ipynb > merged.ipynb
full documentation - https://github.com/jbn/nbmerge
You can indeed copy multiple cells at a time - use Shift + J or Shift + Down to select the next cell in a downwards direction, and in an upwards direction with Shift + K or Shift + Up. You could then copy and paste them en masse to another notebook, and preserve the cell divisions by making sure the destination notebook is in Command mode (cells have blue border).
See http://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Notebook%20Basics.html# and https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/.
install nbmerge:
pip install nbmerge
run the following:
!nbmerge file_1.ipynb file_2.ipynb file_3.ipynb > merged.ipynb
Answer for those who missed to exclaim
I've done this sort of thing a few times in the past using a text editor on the .ipynb file. It's a json format that's fairly easy to follow. My use case was to move a series of cells into another notebook, more or less as an archive activity.
Make sure you have a backup strategy in place in case you break the json format by leaving out a comma or some such!
You end up with an invalid checksum, which you are warned about when you first open the changed notebook(s). After saving them the first time, a new checksum is created and the warning goes away.
Make sure all the notebooks you want to merge are in the same folder/directory and put these code in new jupyter cell (pls don't forget the exclamation mark)
!nbmerge file_1.ipynb file_2.ipynb file_3.ipynb > merged_ouput.ipynb
You should have a look at the following issue on GitHub which tracks this feature. It will likely be made possible via a command line tool. The issue also links to scripts to do that.
Copy-Pasting cells between browser windows is unfortunately a tricky problem, as browser security often prevents getting enough data to do so. It might be possible in some cases using some third party extensions.
Copy/pasting parts of a notebook into another one is a use case for Jupytext. Jupytext can export (the inputs) of your notebooks as .py or .md files. Execute either
jupytext --set-formats ipynb,py --sync *.ipynb
or
jupytext --set-formats ipynb,md --sync *.ipynb
Then edit the text files, move the desired inputs from one file to the other, and update the corresponding .ipynb files with
jupytext --sync *.ipynb
Please note that only the outputs for which the inputs were unchanged are preserved in this operation.
Jupytext is also available as a plugin for Jupyter. In that context, you don't need to use the command line. You can pair your notebook to the desired text file using the File/Jupytext menu (Jupyter Notebook) or the Jupytext commands (Jupyter Lab). And you just have to refresh your paired notebook in the browser to get the latest edits on the paired text file.
First, create a new Jupyter Notebook in the same directory as the previous notebooks you wish to merge.
In the new Jupyter Notebook, run this: pip install nbmerge .
Then, restart your Kernel.
Finally, run this:
!nbmerge your_first_file.ipynb your_second_file.ipynb your_third_file.ipynb -o merged.ipynb
Check your directory for the newly created merged file (merged.ipynb)
You would first have to create a new Notebook in the same directory as the notebooks you wish to merge.
then type the following:
pip install nbmerge
import nbmerge
!nbmerge name1.ipynb name2.ipynb name3.ipynb -o new_name.ipynb
This should work
I've recently updated IPython (to 4.0) and have started using Notebooks after a period of some time not using them (since before The Big Split, I think), and have discovered that some of my settings need to be modified and moved from ~/.ipython/ to ~/.jupyter/.
For example, it appears that the NotebookManager.notebook_dir in
~/.ipython/profile_default/ipython_notebook_config.py
is ignored and has had its functionality replaced by FileContentsManager.root_dir in
~/.jupyter/jupyter_notebook_config.py
Beyond isolated incidents like this, however, it's not clear to me how the configuration settings and profiles now work. In particular what files should be located where, and what they should contain. If, for example, I generate a new profile with
ipython profile create foo
I now get different files than I used to (and than those present in my existing profiles): where I used to get
ipython_config
ipython_notebook_config.py
ipython_nbconvert_config.py
I now get
ipython_config.py
ipython_kernel_config.py
and as near as I can tell, none of my ipython_notebook_config.py are used.
This (and the limited documentation) all leaves me a bit confused about where should I place my settings and profiles for use with IPython/Jupyter 4.0, specifically:
Where should I place general notebook-related settings for use by all kernels/profiles? (I see that some go in ~/.jupyter/jupyter_notebook_config.py, but it's not clear to me whether these would override settings loaded from elsewhere.)
Where should I place profile-specific settings for use with notebooks? (Can I continue to use ipython_notebook_config.py files in ~/.ipython/profile_someprofile/ directories?)
Where should I place kernel-specific settings for use by all profiles and applications. (For example, where should settings used by IPython for all profiles in both the shell and notebooks go?)
How should I modify or update existing IPython profiles for use with 4.0.0? (For example, should all have a ipython_kernel_config.py file; should I delete the ipython_notebook_config.py and ipython_nbconvert_config.py files?)
OS X 10.10.4; Xcode 6.4; CLT: 6.4.0.0.1; Clang: 6.1; Python Python 2.7.10 (Homebrew); Jupyter 4.0.4; IPython 4.0.0.
First of all, check what's in your ~/.jupyter/ folder. Some of the comments under the question mention you have a file named "MIGRATED" that contains only a timestamp.
If you are in this state, run the command: jupyter notebook --generate-config which will create a new file ~/.jupyter/jupyter_notebook_config.py. If you already have this file, you don't need to run this command.
This file is where you put the code that will modify your IPython Notebook behavior. It's a fully commented out (and well documented) file.
I have a related question open (How do I get IPython profile behavior from Jupyter 4.x?) that deals with attempting to set up multiple profiles, which is currently unanswered.
I'm working on 2 branches in SVN and I'd like to have 2 shortcuts (or 2 .bat files) to start matlab with path correctly defined upon the branch I'm currently working with. For instance:
[Matlab-trunk.bat] ==> Would look for some pathdef-trunk.m
~matlabroot\toolbox\matlab\apps
~matlabroot\toolbox\matlab\audiovideo
~code\trunk\MyToolboxes\Common
~code\trunk\MyToolboxes\Miscellaneous
~code\trunk\MyToolboxes\etc\etc ...
[Matlab-BranchLala.bat] ==> Would look for some pathdef-lala.m
~matlabroot\toolbox\matlab\apps
~matlabroot\toolbox\matlab\audiovideo
~code\branchlala\MyToolboxes\Common
~code\branchlala\MyToolboxes\Miscellaneous
~code\branchlala\MyToolboxes\etc\etc ...
I have read this thread:
How to run two MATLAB instances simultaneously with different pathdef's?
And I like the solution where I would simply have to define for MATLABPATH environment variable before to start Matlab ... but it seems this only works for Unix\Mac platforms ... maybe I should mimic similar idea by manually editing the matlabrc.m file ... or maybe you have a better idea ?
EDIT
Humm ... maybe I should dynamically switch startup.m file before to start and add a matlabpath(...) in there ... but I don't know where it is stored, the command userpath is returning `` on my PC.
NB1: I'm working with Matlab R2013b on a PC platform
NB2: I cannot move to git do in-place branch-switching for now on (this was one solution I though about).
You can define different startup folders for each of the shortcuts.
Then, at each different startup folder define pathdef.m file with the different paths.
Im trying to introduce IPython notebook in my work. One of the ways I want to do that is by sharing my own work as notebooks with my colleagues so they would be able to see how easy it is to create sophisticated reports and share them.
I obviously can't use Notebook viewer since most of our work is confidential. I'm trying to set up notebook viewer locally. I read this question and followed the instructions there, but now that nbconvert is part of IPython the instructions are no longer valid.
Can anybody help with that?
You have a couple of options:
As described above convert to HTML and then serve them using a Simple server e.g python -m "SimpleHTTPServer" You can even set up a little python script that would "listen" in one directory. If changes or new notebooks is added to the directory the script will run nbconvert and move the HTML file to the folder you are serving from. To navigate to the server you are running go to yourip:port e.g. 10.0.0.2:8888 (see the IPython output when you run the IPython notebook command) (If you can serve over the network you might just as wel look into point 2 below)
If your computers are networked you can serve your work over the lan by sharing your IP address and port with your colleagues. This will however give them editing access but should not be a problem? This means that they will navigate to your ipython server and see the ipython notebook and be able to run your files.
Host your notebooks on an online server like Linode etc... entry level servers cheap. Some work is needed to add a password though.
Convert to PDF and mail it to them.
Convert to a slideshow (now possible in Version 1.00) and serve via option 1,2 or just share the HTML file with them.
Let them all run ipython notebook and check your files into a private repo at bitbucket (its free private git repo). They can then get your files there and run it themselves on their own machines.Or just mail it to them. Better yet if they wont make changes share a dropbox folder with everyone. If they run ipython notebook in that folder they will see your files (DANGEROUS though)
Get them in a boardroom and show them. :)