how to change ipython notebook directory to save the notebooks in dropbox? - ipython

I've installed anaconda on windows 7 and I would like to save my notebooks on dropbox to have easy access from another pc. How can I change the directory in which my notebooks saved there?

Related

Jupyter Lab export as executable save location

I'd like to save an executable version of a python kernel notebook in the same directory as the actual notebook. Exporting as executable currently puts a download in the downloads folder (OSX). Is there a variable I need to change so that executables are saved in current directory?

VSCode can't write to files in Bash for Windows

I've been using Bash for Windows recently (its the Ubuntu "app") and I can open VSCode from the bash command line but when I try to save any modifications I've made to the file, it just says permission denied.
I've tried creating the files directly from VS Code's terminal but in that case it doesn't print out an error message but it also doesn't save anything.
That happens because you dont have permissions to write in the system32 folder. If you run the Ubuntu application as an administrator, you'll get the permissions to write. However, you won't be really in that file, because of the way that the virtualization of files and errors might happear doing so, and I do not recommend to run the console in a privilege mode (for seccurity issues).
Fortunately, in version 1903 of Windows 10, this will change, and you'll be able to navigate the WSL folders via Windows Explorer, and for sure that issue will disappear.
Edit: the best practice, you do the work in a folder in the Windows File System, and cd to there in the WSL console. VSCode has this integrated very well, if you have an open file in VSCode you can just do New Terminal and choose a WSL terminal. The terminal will already be in the folder where you file is.

create Jupyter file in any location of my computer

I want to create a new jupyter file in any location of choice of my computer other than in the default folder. I am using windows 10. Just like any other applications, word, R etc, you have the choice to create and save it in anywhere but I could not figure out how to do that in jupyter.
When you are starting jupyter-notebook, first go to the desired directory where you want to create or save file and then start the notebook. Now, jupyter will run in that directory. You will be able to save your work (ex., ipynb files) in that directory.
I follow this whenever I work with jupyter notebook. I prefer this approach because in this way, you can start the jupyter-notebook in any desired directory.
You can see the official instruction to change the startup folder for jupyter-notebook in windows.
You can also do the following: using the jupyter notebook config file.
Open cmd and type jupyter notebook --generate-config
This writes a file to C:\Users\username.jupyter\jupyter_notebook_config
Change line 179. c.NotebookApp.notebook_dir = '' to c.NotebookApp.notebook_dir = 'your path'. [Make sure you use forward slashes in your path]
But you need to do this every time you want to start jupyter-notebook in a different directory. Thats why I don't prefer this approach (personal opinion).
You can this stackoverflow post too, in case if you get any help from it.

Changing Jupyter Notebook start location [Win 7 Enterprise]

I am trying to change the default Jupyter Notebook start directory on my Windows 7 Enterprise machine. Other answers have suggested changing the "Start In" field found through Right-click>Properties>Shortcut on the Jupyter program in my Start menu, however this doesn't have any effect. When I change this field to my desired directory and try running the program it still opens in the default directory, when I recheck the "Start In" field it is the same as whatever I had changed it to so it looks like it isn't being changed back by Windows, rather it's being disregarded entirely. For reference the default directory is at P:\ which is not a local directory and is hosted on my company servers, and I am trying to change the Jupyter startup directory to C:.
I'm sure the path is correct - I've tried a few different ones and they are working with autocomplete. I should mention this is a locked down corporate machine and I have to run Jupyter as administrator or else it exits immediately. I do have elevated rights and have checked the user permissions on Jupyter. This is using the Jupyter that comes as default with the current Python 3.5 distribution of Anaconda - I have also tried reinstalling the whole Anaconda package and I'm currently working with a fresh default install.
I am wondering if there is perhaps a way through changing the startup script that is run when you execute the program?
Found the solution - go to your Anaconda install directory (for me this was C:\Anaconda3) and open the file cwp.py in a text editor. Change the line
os.chdir(documents_folder)
to
os.chdir("C:\\my\\path\\here").

How to limit ipython notebook directory access

I'm running ipython notebook server on the cloud and i want to expose this as a service so that users can play around with the notebook, i noticed that using notebook i can access the filesystem and inspect files on the filesystem, i want to limit this access.I want only special folders to be accessible from ipython notebook.
You can launch your iPython notebook in the folder that you want the server to have access to, and the user won't be able to go to the parent directory, but you should realize that when the user launches a kernel, they will be able to chdir to any folder in the file system.
So if you want to limit access to users of the iPython notebook, you should use unix file permissions to jail the user to their starting folder.
The way I would do this is to:
Create an ipython user that doesn't belong to any existing user groups
Create a folder for the ipython user (cloud for instance)
Launch the iPython notebook as ipython in the cloud folder