# How to change the default JULIA\_NUM\_THREADS variable? How to call a multi thread julia from a python script?

**URL:** <https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727>\
**Category:** General Usage\
**Tags:** pycall, multithreading, python, environment\
**Created:** [April 7, 2021, 1:29am UTC](https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727 "2021-04-07T01:29:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noodle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noodle/32/22901_2.png) [@Noodle](https://discourse.julialang.org/u/Noodle)\
**Post date:** [April 7, 2021, 1:29am UTC](https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727/1 "2021-04-07T01:29:16Z")

</div>

Hello everyone,

Is there a way to change the DEFAULT number of threads (default is 1) so that every time I use julia.exe it always starts with 4 threads?

I know we could manually set it by

set JULIA\_NUM\_THREADS = 4 and then run Julia,

but I can not do that because I am using pyjulia and I want to call a multi-threading julia script from a python script.

So I am thinking of two potential solutions

(1) change the default JULIA\_NUM\_THREADS so it starts with multi threads

(2) specify the number of threads in python while using pyjulia (have no idea how to do it).

Any thoughts or suggestions? Thank you!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [April 7, 2021, 7:23am UTC](https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727/2 "2021-04-07T07:23:22Z")

</div>

Try setting the environment variable via Python:  
[https://docs.python.org/3/library/os.html#os.environ](https://docs.python.org/3/library/os.html#os.environ)
