# Fatal Python error when running Julia on mac m1 VS Code

**URL:** <https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [January 31, 2024, 11:31pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540 "2024-01-31T23:31:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salvator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salvator/32/50764_2.png) [@Salvator](https://discourse.julialang.org/u/Salvator)\
**Post date:** [January 31, 2024, 11:31pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/1 "2024-01-31T23:31:47Z")

</div>

Hi everyone! I’m kinda used to Julia given some courses on stochastic simulations and I have never got a problem.  
Now I’m struggling with an error which makes the kernel to crash: I’m running Julia1.6.3 on VS Code and when I start the repl and type `using PyPlot ` the below error message appears.  
I did some research and tried different solutions from other people who had similar problems but I did not find anything useful that could work.  
Could anybody explain me the problem? Thanks in advance

````Info
Python path configuration:
  PYTHONHOME = '/Users/salvatorecandita/.julia/conda/3:/Users/salvatorecandita/.julia/conda/3'
  PYTHONPATH = (not set)
  program name = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/Users/salvatorecandita/.julia/conda/3/lib/python3.12'
  sys._base_executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.base_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.base_exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.path = [
    '/Users/salvatorecandita/.julia/conda/3/lib/python312.zip',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001e387dc40 (most recent call first):
  <no Python frame>
  ✗ PyPlot
  0 dependencies successfully precompiled in 1 seconds. 17 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]

Failed to precompile PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] to "/Users/salvatorecandita/.julia/compiled/v1.10/PyPlot/jl_JBHDRp".
Python path configuration:
  PYTHONHOME = '/Users/salvatorecandita/.julia/conda/3:/Users/salvatorecandita/.julia/conda/3'
  PYTHONPATH = (not set)
  program name = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/Users/salvatorecandita/.julia/conda/3/lib/python3.12'
  sys._base_executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.base_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.base_exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.path = [
    '/Users/salvatorecandita/.julia/conda/3/lib/python312.zip',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001e387dc40 (most recent call first):
  <no Python frame
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{…}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{…})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:1656
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
  [4] precompile
    @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
  [5] #precompile#114
    @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
  [6] #invokelatest#2
    @ Base ./essentials.jl:889 [inlined]
  [7] invokelatest
    @ Base ./essentials.jl:884 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1957
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1806
 [10] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [11] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1797
 [13] macro expansion
    @ Base ./loading.jl:1784 [inlined]
 [14] macro expansion
    @ Base ./lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1747
 [16] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [17] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1740
 [19] eval
    @ ./boot.jl:385 [inlined]
 [20] eval
    @ ./Base.jl:88 [inlined]
 [21] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/repl.jl:229
 [22] (::VSCodeServer.var"#110#112"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/repl.jl:192
 [23] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [24] with_logger
    @ ./logging.jl:627 [inlined]
 [25] (::VSCodeServer.var"#109#111"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/repl.jl:193
 [26] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [27] invokelatest(::Any)
    @ Base ./essentials.jl:884
 [28] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:34
Some type information was truncated. Use `show(err)` to see complete types.```
````

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 1, 2024, 9:33am UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/2 "2024-02-01T09:33:11Z")

</div>

please check [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![Salvator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salvator/32/50764_2.png) [@Salvator](https://discourse.julialang.org/u/Salvator)\
**Post date:** [February 1, 2024, 9:53am UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/3 "2024-02-01T09:53:35Z")

</div>

Sorry Eben, I tried my best to post it correctly but It’s the first time… now is it ok?

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 1, 2024, 11:18am UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/4 "2024-02-01T11:18:41Z")

</div>

Now it’s better readable, thank you 🙂

> [@Salvator](#):
>
> I’m running Julia1.6.3 on VS Code

> [@Salvator](#):
>
> ```julia
> [1] pkgerror(msg::String)
> @ Pkg.Types ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
> 
> ```

Could it be somehow a reason (Julia 1.6.3 vs 1.10.0)?

Is there a good reason you are sticking with with 1.6 (apart from 1.6 being LTS)? Generally it is recommended for most users to use the last stable version. Also, it is possible to use PyPlot via Plots.jl frontend AFAIK, maybe that could work.

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 1, 2024, 6:02pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/5 "2024-02-01T18:02:34Z")

</div>

> [@Eben60](#):
>
> Could it be somehow a reason (Julia 1.6.3 vs 1.10.0)?

Just checked: 1.6.3 is not even LTS, LTS is 1.6.7.

Specifically for Apple Silicon one should avoid using an old Julia version IMO.

---

<div class="post-metadata">

**Author:** ![Salvator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salvator/32/50764_2.png) [@Salvator](https://discourse.julialang.org/u/Salvator)\
**Post date:** [February 1, 2024, 6:17pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/6 "2024-02-01T18:17:55Z")

</div>

First of all, thanks for your support.  
I can swear that I did it by downloading and installing the new version from Julia downloads, I also now tried to do it through JuliaUpdate but got this stacktrace:

```julia
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] v_url(version_str::String, os_str::String, arch_str::String, prefer_gui::Bool)
   @ UpdateJulia ~/.julia/packages/UpdateJulia/nPbih/src/UpdateJulia.jl:125
 [3] update_julia(version::String)
   @ UpdateJulia ~/.julia/packages/UpdateJulia/nPbih/src/UpdateJulia.jl:166
 [4] update_julia()
   @ UpdateJulia ~/.julia/packages/UpdateJulia/nPbih/src/UpdateJulia.jl:177
 [5] top-level scope
   @ REPL[5]:1

```

---

<div class="post-metadata">

**Author:** ![Salvator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salvator/32/50764_2.png) [@Salvator](https://discourse.julialang.org/u/Salvator)\
**Post date:** [February 1, 2024, 6:36pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/7 "2024-02-01T18:36:47Z")

</div>

I managed to install Julia 1.10 also in VS Code, the error is still present, to me it seems an error in python directory but I can’t understand

```julia
Python path configuration:
  PYTHONHOME = '/Users/salvatorecandita/.julia/conda/3:/Users/salvatorec
andita/.julia/conda/3'
  PYTHONPATH = (not set)
  program name = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/Users/salvatorecandita/.julia/conda/3/lib/python3.12'
  sys._base_executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.base_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.base_exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/salvatorecandita/.julia/conda/3/bin/python'
  sys.prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.exec_prefix = '/Users/salvatorecandita/.julia/conda/3'
  sys.path = [
    '/Users/salvatorecandita/.julia/conda/3/lib/python312.zip',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12',
    '/Users/salvatorecandita/.julia/conda/3/lib/python3.12/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001e387dc40 (most recent call first):
  <no Python frame>

```

it seems a slight different error but still does not work

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 1, 2024, 6:45pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/8 "2024-02-01T18:45:27Z")

</div>

If you installed Julia on a Mac by downloading DMG file (which is how it is installed on my computer), you probably should also set the PATH.

Also, even though you already have the current Julia version, installing `juliaup` could help.

---

<div class="post-metadata">

**Author:** ![Salvator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salvator/32/50764_2.png) [@Salvator](https://discourse.julialang.org/u/Salvator)\
**Post date:** [February 1, 2024, 7:08pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/9 "2024-02-01T19:08:10Z")

</div>

Sorry Eben, I really don’t have any knowledge regarding these stuff…It seems that I have Juliaup but the install from the command line did not work so I went for dmg installation which did not require any path definition  
This is what I get from my terminal

```julia
It seems that Juliaup is already installed on this system. Please remove the previous installation of Juliaup before you try to install a new version.

```

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [February 1, 2024, 7:27pm UTC](https://discourse.julialang.org/t/fatal-python-error-when-running-julia-on-mac-m1-vs-code/109540/10 "2024-02-01T19:27:58Z")

</div>

[Document How To Uninstall · Issue #240 · JuliaLang/juliaup · GitHub](https://github.com/JuliaLang/juliaup/issues/240) mentions

`juliaup self uninstall`
