IPython notebook Jupyter cannot download as .py - jupyter-notebook

After I open Jupyter and write down codes, I want to download it as .py file, but it is always downloaded as HTML. How can I fix it?

Try refreshing the web page and download as .py should show up.

You may need to zoom out on your browser in order to see the options below html. With jupyter notebook, if the browser is zoomed in then some options may fall off the bottom of the browser.

Related

How to open an external file from a Colab Jupyter notebook?

I have a Jupyter notebook in which I create an HTML file. I then open this HTML file in a new browser tab.
It's an R analysis, so I opened the HTML file using browseURL().
However, when I use a Colab hosted version of the notebook, nothing happens when I try to open the page.
Here's a reproducible example: https://colab.research.google.com/drive/1BfVDsDnXQwEpy4HwPKWkUC9Bpaz6r0Kv
Other things I tried that didn't work:
Using system2() instead of browseURL().
Setting the browser option to the open system tool via options(browser = "/usr/bin/open").
Is there another value for browser I should use? Is there a permission setting I should change?
Otherwise, how can I get the Colab notebook to display the HTML page I created?
As far as I know, Colab stores its files in Google Drive and judging by this link, Google doesn't support serving HTML from there.
You could save them as png files and display them like this if you're OK to have to install a few extra libraries.
install.packages('webshot')
webshot::install_phantomjs()
library(webshot)
webshot('https://www.halfbakery.com/', 'hb.png', delay = 2)
install.packages("png")
library(png)
img <- readPNG('hb.png')
grid::grid.raster(img)
I have tried it in Colab and it works there. I should add that browseURL still doesn't work on the file although double clicking on the file in the Files page does bring up a window with the png correctly displayed.

Rstudio save and open blank Rmarkdown file

My Rmarkdown file appears to completely blank. I wrote my homework in a Rmarkdown file in Rstudio. But when I open it this morning, file Knit gave me blank windows.
Then, to check the setup way of previous Rmd, I open one Rmd file but Rstudio shown a blank file again.
So I follow the advice on the internet to "Reopen with Encoding", UTF-8 turned out helpful to show my previous Rmd.
But, when I click "Reopen with Encoding" on my hw4, all content disappeared, and none of encoding looks right for my hw4.
And I believe I did something with encoding last night when saving the file, because the final project blocked down R session for a couple of times and some windows jumped out to save the files with certain encoding. I also noticed that in direction the rmd file are 0KB, and Jupyter Notebook also open a blank file for me.
How can I recover the content of hw4 content? Are there any chance to recover it or I can just rewrite the whole file?

Trying to use live server package on text editor atom

I am trying to use the live server package which works pretty much like livereload for editor Atom. The server runs fine, but the files do not get automatically refreshed whenever I make changes + save the files..
Not sure if this is normal, but when I open up the server on the browser, I am forwarded to a directory with all the files on the server. How do I change this so that the server renders HTML only and refreshes every time changes are made?
My php files with html elements dont open, so create the file like .html files, and everythings runs well. Use .atom-live-server.json on the root project to change some options like other browsers.
Edit 1: Have the solution !
1- Install Live Reload from livereload.com.
2- Install Live Reload from browser extension.
3- Copy and paste this before before body:
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
4- Execute live reload and the browser and still works for php files.
You haven't set the project folder for the live-server to operate from, or you've saved the file you want to view outside of where it is running from.
In the project window on the left, add the project folder that you are using, and remove anything else. Or save your file in that location.
I had the same problem with atom-live-server and Google Chrome browser. Finally made it work using these steps:
Open your Browser
In Project pane open the project folder that you want to test
Start the atom-live-server
It should automatically open a new page in your browser. Right click on it and select Inspect -> it will open Console window.
Your Live reload is enabled. Notice the message in the Console.
After you make changes in your javascript or html in Atom save your changes (Ctrl + S) and the browser page will be updated.
I fixed it by adding the <head> and <body> tags to the html file I was editing. (even though I don't always include them anymore at least one is needed for the "Live reload" server to work.)
Live reload won't work unless there's a tag in the HTML the script can be injected on (body, head, and svg).
see this github issue!

Upload any file to ipython notebook directory

I have the following line on the notebook home page:
To import a notebook, drag the file onto the listing below or click here.
When I upload a text or any other file, I get an error message:
Invalid file type
Uploaded notebooks must be .ipynb files
How do I make it possible to upload any file ?
Is there any setting/ add on that will allow this?
This is now implemented on master (futur 3.0), we now have the content webservice which can deal with non-ipynb file. Just drag file onto the dashboard and it works(tm).
Keep in mind that this upload on the machine were the webserver is, not the machines were the kernels run in case they are not the same.

How to make RStudio File Navigator open Current Working Directory by default?

This is a very small issue but every time I do it, I wonder if there is such a convenience.
In RStudio, file navigator always opens in home directory by default. Is there a way to make it open the current working directory automatically or by using a shortcut?
To open current working directory you can simply use the "Set As Working Directory" button in Files -> More menu.

Resources