# Export julia code from VSCode to html

**URL:** https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480
**Category:** General Usage
**Tags:** question
**Created:** [July 25, 2024, 3:50pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480 "2024-07-25T15:50:56Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 25, 2024, 3:50pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/1 "2024-07-25T15:50:56Z")

</div>

Hi everybody !  
Some IDEs for instance Pycharm propose export to html format directly from the main menu .  
I decided to shift to VSCode (Visual Studio) and expected the same. In vain …  
So I began to understand that it was only possible through JuPyter notebook.  
I downloaded the JuPyter extension from VSCode and was able to create a new notebook from inside VSC and paste any code inside the cell.  
Now i followed instructions to export the resulting i.pynb file.  
Drop down menu ‘…’ on the right of tool-bar actually proposes ‘Export’ and asks for format (choice between PDF and HTML ,quite simple and logical). After selection I have a dialog box to select a file name for the output. Well, quite normal again.  
After my choice is done NOTHING happens ! NO file is created, NO error message is issued.  
I did several attempts with the same (absence of) result.  
Did I miss something, did I forget something about parameters.  
Thank you for your help.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [July 25, 2024, 7:57pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/2 "2024-07-25T19:57:23Z")

</div>

Did you install python?

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 6:10am UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/3 "2024-07-26T06:10:59Z")

</div>

No I didn’t

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [July 26, 2024, 9:40am UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/4 "2024-07-26T09:40:04Z")

</div>

I’ve had a similar problem wrt. exporting a Jupyter notebook as html from VSCode on _Windows_. I seem to recall that I had to install Python and possibly some package. I never recall what I had to install, though. It is possible that this is simpler on Linux or Mac – I think those have Python installed as part of the OS.

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 3:20pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/5 "2024-07-26T15:20:57Z")

</div>

@ BLI  
Thank you very much. It works !

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 3:28pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/6 "2024-07-26T15:28:51Z")

</div>

Another problem which is reported elsewhere.  
Running of very simple Julia scripts through ‘run’ menu of VSCode is **very long**. Somebody suggested to use command ‘Julia: execute active file in REPL’ result is a little better but nothing to compare with ‘real’ REPL. So it seems to me that I will keep VSCode as a pure editor, debugger but that I will run files ‘from outside’ (REPL or linux notepadqq almost as fast as REPL)

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [July 26, 2024, 3:50pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/7 "2024-07-26T15:50:23Z")

</div>

Hm. How “simple” is your code in VSCode?

Be aware of that the first time you run Julia code, there is an overhead in “compiling” the functions you use. If you run the code a second time, it runs much, much faster.

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 7:47pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/8 "2024-07-26T19:47:52Z")

</div>

This code for instance:  
Purpose is to compare this (searching for perfect numbers \<1000000):  
function sommeAliquotes(n)  
“”“calcule la somme des diviseurs propres de n à l’exclusion de n “””  
somme = 1  
stop = sqrt(n)  
i = 2  
while i \< stop #condition d’arrêt  
if rem(n, i) == 0  
somme += i + div(n, i)  
end  
i += 1  
end  
if n == i \* i # cas des carrés parfaits n/i=i  
somme += i  
end  
return somme  
end

parfait(n) = ifelse(sommeAliquotes(n) == n, true, false)#si immédiat

function show()  
for n in 2:1000000  
if parfait(n)  
println(n)  
end  
end  
end

@time show()

with Python equivalent :

import math, time  
def sommeAliquotes(n: int) -\>int:  
somme = 1  
i=2  
stop = math.sqrt(n)  
while i\<stop:  
if not n%i:  
somme=somme+i+n//i  
i=i+1  
if i\*i==n:  
somme+=i  
return somme

def parfait(n):  
return n==sommeAliquotes(n)

debut=time.time()  
for n in range(2,1000000):  
if parfait(n):  
print(n)  
fin=time.time()  
print(fin-debut)

Actually on this example Julia is always 20 times faster than Python.  
But REPL gives immediately  
**4.428420 seconds** (7.16 k allocations: 527.172 KiB, 1.01% compilation time)  
and run without debugging gives this result  
**15.350995 seconds** (262.84 k allocations: 18.144 MiB, 0.25% gc time, 6.38% compilation time)  
but actually to have this output you must wait more than 20 seconds  
Now command: Julia run active file in REPL gives  
**6.023399 seconds** (7.18 k allocations: 523.000 KiB, 0.91% compilation time)  
But you must wait the same more than 20 seconds for this output.

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 7:50pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/9 "2024-07-26T19:50:46Z")

</div>

> [@BLI](#):
>
> Be aware of that the first time you run Julia code, there is an overhead in “compiling” the functions you use. If you run the code a second time, it runs much, much faster.

This was visible with version 1.6. i do not notice anything with 1.10

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [July 26, 2024, 8:10pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/10 "2024-07-26T20:10:05Z")

</div>

> [@Gilles\_Dubois](#):
>
> This code for instance:  
> Purpose is to comp

Suggestion: Please insert code in a standard Julia computer code environment. In-line code is inserted between back-ticks, while multiline code is inserted between triple backtick followed by “julia”, and ends in triple backtick. This makes it much easier to read the code. Your first function would then be:

```julia
function sommeAliquotes(n)
    """calcule la somme des diviseurs propres de n à l’exclusion de n """
    somme = 1
    stop = sqrt(n)
    i = 2
    while i < stop #condition d’arrêt
        if rem(n, i) == 0
            somme += i + div(n, i)
        end
        i += 1
    end
    if n == i * i # cas des carrés parfaits n/i=i
        somme += i
    end
    return somme
end

```

next,

```julia
parfait(n) = ifelse(sommeAliquotes(n) == n, true, false)#si immédiat

```

and

```julia
function show()
    for n in 2:1000000
        if parfait(n)
            println(n)
        end
    end
end

```

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [July 26, 2024, 8:29pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/11 "2024-07-26T20:29:01Z")

</div>

> [@Gilles\_Dubois](#):
>
> This was visible with version 1.6. i do not notice anything with 1.10

When I run your code in the REPL of my home PC (AMD Ryzen 9 5900HX with Radeon Graphics @ 3.3 GHz, 32 GB RAM):

```julia
julia> @time show()
6
28
496
8128
  1.163568 seconds (7.16 k allocations: 527.172 KiB, 1.77% compilation time)

```

The second time I run it in the REPL, I get:

```julia
julia> @time show()
6
28
496
8128
  1.145218 seconds (22 allocations: 928 bytes)

```

The third and so on time, there are 21 allocations with 624 bytes. OK – in this case, compilation time is not important (it doesn’t take much time), but there is a significant reduction in the allocations.

* * *

If I run your code in Jupyter notebook within VSCode, I get the following results… the first time:

```julia
julia> @time show()
1.166460 seconds (14.94 k allocations: 1.198 MiB, 1.94% compilation time)

```

while the subsequent times:

```julia
julia> @time show()
1.138408 seconds (53 allocations: 1.406 KiB)

```

So: I essentially get the same computation time in the REPL and in VSCode/Jupyter notebook, but a bit more allocation in VSCode/Jupyter notebook.

My computer seems to be quite a bit faster than yours. That doesn’t explain the hike in the computation time on your computer when running the code in VSCode/Jupyter notebook. Perhaps your computer has less RAM than mine?

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 10:24pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/12 "2024-07-26T22:24:56Z")

</div>

No doubt !  
Here are my characteristics  
System: Kernel: 5.4.0-186-generic x86\_64 bits: 64 compiler: gcc v: 9.4.0  
Desktop: Cinnamon 4.6.7 wm: muffin dm: LightDM Distro: Linux Mint 20 Ulyana  
base: Ubuntu 20.04 focal  
Machine: Type: Laptop System: ASUSTeK product: VivoBook\_ASUSLaptop X409BA\_M409BA v: 1.0  
serial:   
Mobo: ASUSTeK model: X409BA v: 1.0 serial: UEFI: American Megatrends  
v: X409BA.300 date: 09/10/2019  
Battery: ID-1: BAT0 charge: 22.3 Wh condition: 22.3/32.0 Wh (70%) volts: 7.6/7.6  
model: ASUSTeK ASUS Battery serial: status: Discharging  
CPU: Topology: Dual Core model: AMD A9-9425 RADEON R5 5 COMPUTE CORES 2C+3G bits: 64  
type: MCP arch: Excavator L2 cache: 1024 KiB  
flags: avx avx2 lm nx pae sse sse2 sse3 sse4\_1 sse4\_2 sse4a ssse3 svm bogomips: 12376  
Speed: 3420 MHz min/max: 1400/3100 MHz Core speeds (MHz): 1: 2883 2: 2778  
But my purpose is to motivate teachers to change Python for Julia. Of course for education speed is not the more important but it can be taken into account for some ‘explorations’ in the field of numbers.

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 10:47pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/13 "2024-07-26T22:47:47Z")

</div>

> [@BLI](#):
>
> Suggestion: Please insert code in a standard Julia computer code environment. In-line code is inserted between back-ticks, while multiline code is inserted between triple backtick followed by “julia”, and ends in triple backtick. This makes it much easier to read the code. Your first function would then be:

You’re completely right. For multi-line comment I did this ‘à la Python’. If it doesn’t cause any error if forces the interpreter to evaluate a string constant. I use both languages and sometimes I’m confused. i will take care in the future  
This doesn’t explain my problem delay in execution under VSCode. Difference of performance with your system is quite normal, but your result although better are more consistent. Size of my RAM 8GB maybe the problem is here . IDE are greedy. I will make some additional checking using conky

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 26, 2024, 10:55pm UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/14 "2024-07-26T22:55:29Z")

</div>

Things begin to be clear. 8 GB RAM is sufficient although largely used by the process.  
But it seems that t **he problem comes from the CPU.** Conky signals CPU1-CPU2 100% used under VSCode. Only 40% with notepadqq or REPL.  
This is a hardware problem.  
You helped me very much. Thanks again.

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [July 27, 2024, 2:03am UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/15 "2024-07-27T02:03:58Z")

</div>

> [@Gilles\_Dubois](#):
>
> > [@BLI](#):
> >
> > Suggestion: Please insert code in a standard Julia computer code environment. In-line code is inserted between back-ticks, while multiline code is inserted between triple backtick followed by “julia”, and ends in triple backtick. This makes it much easier to read the code. Your first function would then be:
> 
> You’re completely right. For multi-line comment I did this ‘à la Python’. If it doesn’t cause any error if forces the interpreter to evaluate a string constant. I use both languages and sometimes I’m confused. i will take care in the future

In case it’s not clear, BLI’s suggestion regards the text input _here on Discourse_. The idea is to use Markdown to achieve more readable formatting. This input:

````md
```julia
if rem(n, i) == 0
    somme += i + div(n, i)
end
```

````

Renders like so:

```julia
if rem(n, i) == 0
    somme += i + div(n, i)
end

```

Wikipedia page on Markdown:

> **[Markdown](https://en.wikipedia.org/wiki/Markdown)**
>
> Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber created Markdown in 2004, in collaboration with Aaron Swartz, as a markup language that is intended to be easy to read in its source code form. Markdown is widely used for blogging and instant messaging, and also used elsewhere in online forums, collaborative software, documentation pages, and readme files.
> The initial description of Markdown contained ambiguities and raised unanswered qu...

---

<div class="post-metadata">

### Author: ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)
#### Post date: [July 27, 2024, 5:22am UTC](https://discourse.julialang.org/t/export-julia-code-from-vscode-to-html/117480/16 "2024-07-27T05:22:08Z")

</div>

_In case it’s not clear, BLI’s suggestion regards the text input here on Discourse. The idea is to use Markdown to achieve more readable formatting. This input:_  
Thank you nsajko for making things perfectly clear now. Anyway BLI draw my attention on the fact that my multi-line comment was not correct in Julia for this piece of code. Both language Python and Julia, share the same format for online comments only.  
I will remember, Have a good day.
