# How to run a Julia file with PyJulia

**URL:** <https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282>\
**Category:** General Usage\
**Created:** [October 30, 2020, 2:06am UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282 "2020-10-30T02:06:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rita\_Paz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rita_paz/32/19049_2.png) [@Rita\_Paz](https://discourse.julialang.org/u/Rita_Paz)\
**Post date:** [October 30, 2020, 2:06am UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282/1 "2020-10-30T02:06:58Z")

</div>

I have a Julia file called ‘func1.jl’ with two defined functions that uses the ‘LowRankApprox’ package. Julia, it is working well. But I need it to work in Python. When I import to Python, with PyJulia, it doesn’t work. It gives the following error message:

```julia
Traceback (most recent call last):
  File "C:/Tese/problinearpristrunc0201.py", line 10, in <module>
    j.include('func1.jl')
ImportError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: LoadError: ArgumentError: Package LowRankApprox not found in current path:
- Run `import Pkg; Pkg.add("LowRankApprox")` to install the LowRankApprox package.

```

The LowRankApprox package is installed on Julia, although the error message says no. In fact, this is the problem that I don’t know how to solve. If I run another Julia file, without a package installed, with PyJulia it works fine. So the problem is the LowRankApprox package.

I use PyCharm Community 2020.2 and JuliaPro 1.5.2-1. I noticed that this version of Julia has neither Main nor Base. I tried to install it, but it doesn’t work either. : confused

---

<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:** [October 30, 2020, 11:51am UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282/2 "2020-10-30T11:51:35Z")

</div>

Try func2.jl with something trivial like

```julia
function func2(x)
   return 2*x
end

```

This way you may localize the problem.

`Base` module is the Julia language, so to say, it’s always present

---

<div class="post-metadata">

**Author:** ![Rita\_Paz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rita_paz/32/19049_2.png) [@Rita\_Paz](https://discourse.julialang.org/u/Rita_Paz)\
**Post date:** [October 30, 2020, 12:02pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282/3 "2020-10-30T12:02:42Z")

</div>

Thank you for responding!  
I’ve already created a Julia func2.jl file with any function that doesn’t use a Julia package and works well in PyJulia. In other words, the problem is the use of Julia’s LowRankApprox package that I need to work with in Python. Is it because of using PyCharm?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 30, 2020, 12:56pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282/4 "2020-10-30T12:56:02Z")

</div>

Did you instantiate the Julia environment in the directory where the func1.jl file is? You need to open Julia, and then in package manager mode you can

1. activate the environment in the current folder `] activate .`
2. instantiate (or install the dependencies) `] instantiate`

---

<div class="post-metadata">

**Author:** ![Rita\_Paz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rita_paz/32/19049_2.png) [@Rita\_Paz](https://discourse.julialang.org/u/Rita_Paz)\
**Post date:** [October 30, 2020, 1:19pm UTC](https://discourse.julialang.org/t/how-to-run-a-julia-file-with-pyjulia/49282/5 "2020-10-30T13:19:47Z")

</div>

It worked! thank you!  
It looks like I was installing the package in the wrong folder. 😀 😅
